jclaveau / docker-php-multiversion

Provides PHP in multiple versions locally by installing Docker only
MIT License
1 stars 0 forks source link

Docker PHP Multiversion

Use PHP in the version you prefer with nothing more than Docker installed (for development purpose).

Build Status codecov

Install

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

Usage

$ 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

Managing containers

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

Logging

Container configuration

PHP Versions

This docker image provides all PHP versions available in Ondřej Surý's PPA.

Production

For production purpose I recommend jtreminio/php-docker image which provides a light image of PHP in any version of the same PPA.

FPM

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.