A Docker-based solution for executing complex tests against many PHP versions
An abundance or large quantity of something.
...or, I can haz all the PHPs?
What it is
Prophusion allows you to set up your application once, and test it on many PHP versions.
Unlike other Dockerized test environments for PHP, only one docker image is required to run as many PHP versions as you like.
What it isn't
Prophusion is not a testing framework like PHPUnit. It's all at the "ops" level.
You can, of course, run PHPUnit tests within Prophusion, or any other code to test your app.
When to use Prophusion?
- You want to perform integration, validation or system testing against the full range of PHP versions you support.
- You want to perform unit testing against a range of PHP versions right now on your laptop, without pushing code to the cloud.
- Any time you want to make PHP version the variable in an otherwise consistent and reproducible server.
Prophusion in action
How Does it Work?
- A fairly minimal Docker image provides a known environment.
- Image prophusion/prophusion-base provides CLI + FPM
- Image prophusion/prophusion-apache provides a full webserver
- PHP binaries of every release are built for these images and loaded into the container on-demand from prophusion.org.
- PHP version is the single "variable" in a system with all else constant.
How do I test with it?
- Point it at your code
- Usually, mount your code as a volume in the container
- Tell it what PHP version to test with
- Prophusion will consult environment variable PHP_VERSION when the container starts up.
- Tell it to run your tests
- The last argument to docker run, or the contents of environment variable CONTAINER_CMD, are executed.
How do I test with it, part II
- Docker-compose is your friend
- Extend the Prophusion-provided docker images to customize your test environment
- Need MySQL, memcached, etc for full system tests? Just add them to your image!
- Here's an example Dockerfile (from my Curator project)
Why it's better than...
- hub.docker.com/_/php/, official dockerized PHP
- To test multiple versions, you would have to download many images.
- To extend those images, you would have to maintain many (mostly duplicated) Dockerfiles.
- ...And, CI runs in the cloud are going to need to download more, take longer.
By Mike Baynton