Use PHP in the version you prefer with nothing more than Docker installed (for development purpose).
curl -fsSL https://raw.githubusercontent.com/jclaveau/docker-php-multiversion/master/installer.sh | sh
Or with bpkg/bpkg
sudo bpkg install -g jclaveau/docker-php-multiversion
$ php 7.1 spec/phpversion.php
$ 7.1
$ php 7.1 5.6 spec/phpversion.php
$ 7.1
$ 5.6
If you installed PHP locally it's still available but only in the version you installed
$ /usr/bin/php spec/phpversion.php
This works also with phpunit
$ php 7.1 vendor/bin/phpunit
and composer
$ php 7.1 /usr/bin/composer
You can list php-multiversion containers (Supporting all options of docker ps)
$ php containers # all running containers
$ php container # container attached to the current directory
You can kill/rerun containers
$ php kill-containers # all running containers
$ php kill-container # container attached to the current directory
$ php rerun-container # kill then run current container
You can also exec whatever you want in the container attached to your current working dir
$ php container-exec bash
Get the IP of your container
$ php container-ip
host:./log
folder, all the content of container:/var/log
will be placed inside in realtime.php rerun-container
is required if the host:./log
folder is created after the container is run.host:./log
.<container>:/etc
would be overriden by the content of <host>:<your project path>/etc
.php config-container
will prepare a <container>:/etc
having the content <container>:/etc_default
./etc/php
which are read after the loading of all PHP configurations, enabling you to change any option instantly.php 7.4 -i
php container-exec nano /etc/php/7.4/cli/php.ini
but it wouldn't persist after a container restart.This docker image provides all PHP versions available in Ondřej Surý's PPA.
For production purpose I recommend jtreminio/php-docker image which provides a light image of PHP in any version of the same PPA.
My use case is presently centered around php-cli and I have a lot of work before matching my expectations but using it as a multiversion cli provider could be interesting also later.