Super simple Docker images for PHP development.
PHP Versions: 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4
PHP Variants: cli, fpm
Images based on the Official PHP Images
Also installed:
- Composer
- PHP modules
XDebug,PDO MySQL
Pull the latest version:
$ docker pull jestefane/php-devPull a specific version:
$ docker pull jestefane/php-dev:7.4-cliPick between the various images provided in this repository.
(Optionally) Install the Shortcuts:
To use the Docker images more like binaries, we're providing Shortcuts that can easily be installed on your system.
Image names have the following format:
<docker repo>:<php version>-<php variant>-<branch or version>
For convenience, the latest stable version/variant is also tagged as:
<docker repo>:<php version>-<php variant>
Images names:
jestefane/php-dev:7.4-clijestefane/php-dev:7.3-clijestefane/php-dev:7.2-clijestefane/php-dev:7.1-clijestefane/php-dev:7.0-clijestefane/php-dev:5.6-clijestefane/php-dev:5.5-cli
Example:
$ docker run jestefane/php-dev:7.2-cli hello-world.php
# or using one of the provided shortcuts
$ php-7.2-cli hello-world.phpImages names:
jestefane/php-dev:7.4-fpmjestefane/php-dev:7.3-fpmjestefane/php-dev:7.2-fpmjestefane/php-dev:7.1-fpmjestefane/php-dev:7.0-fpmjestefane/php-dev:5.6-fpmjestefane/php-dev:5.5-fpm
Shortcuts: php-fpm
Example:
$ docker run jestefane/php-dev:7.4-fpm hello-world.php
# or using one of the provided shortcuts
$ php-7.2-fpm hello-world.phpNote: Only tested on some distros of Linux and Mac OS. But hey! It's tested ;)
Shortcuts are simple bash scripts wrapping the docker command that facilitate command-line-use of the images in this repository.
From the root of this directory:
# If you haven't done so, clone this repository
$ git clone https://github.com/grimzy/php-dev.git
# Get in there!
# Yes, you have to! the script doesn't always work when running from outside
$ cd php-dev
# Generate the scripts and install the shortcuts
make shortcutsThis generates bash scripts in the scripts directory (via. Script Template). It also adds them to your PATH environment variable (Linux and Mac OS only) by creating symlinks of the generated bash scripts inside /usr/local/bin.
For more info on the shortcuts task, please checkout the Makefile command reference.
Optionally, you can alias your preferred shortcuts by adding them to your ~/.bash_profile:
# Aliases for the jestefane/php-dev preferred versions
alias php="php-7.2-cli"
alias composer="composer-7.2"Note: this is not a perfect replacement for installing PHP on your system.
After saving your
.bash_profile, don't forget to source your changes (. ~/.bash_profile) for them to take effect. Alternatively open a new Terminal session.
You'll notice that the directory that should contain the scripts doesn't exist; that's because you first need to generate them. This is automatically done prior to creating the symlinks. But if you've deleted a script or changed the templates in some way, you can regenerate scripts with:
# Removes the scripts directory and generates them back
$ make scriptsFor more info on the scripts task Makefile command reference.
Images: All respective versions of the PHP CLI variant
Shortcuts: php-5.5-cli, php-5.6-cli, php-7.0-cli, php-7.1-cli, php-7.2-cli, php-7.3-cli, php-7.4-cli
Script template: template/php.template
Images: All respective versions of the PHP FPM variant
Shortcuts: php-5.5-fpm, php-5.6-fpm, php-7.0-fpm, php-7.1-fpm, php-7.2-fpm, php-7.3-fpm, php-7.4-fpm
Script template: template/php.template
Images: All respective versions of jestefane/php-dev images (Composer is installed on every image)
Shortcuts: composer-5.5, composer-5.6, composer-7.0, composer-7.1, composer-7.2, composer-7.3, composer-7.4
Script template: template/composer.template
| Variable name | Description | Default value | Possible values |
|---|---|---|---|
SOURCE_BRANCH |
Appended to the image name. Docker Cloud variable |
Current Git branch: git rev-parse --abbrev-ref HEAD |
Any string value |
DOCKER_REPO |
The Dockerhub repository to perform the tasks against Docker Cloud variable |
jestefane/php-dev |
A Dockerhub repository |
DOCKER_TAG |
A combinaison of one PHP version and one PHP variant to perform a task only one image (for example 7.1-cli)Docker Cloud variable |
Empty | Any PHP_VERSION-PHP_VARIANT combinaison |
PHP_VERSIONS |
Space separated list of PHP versions to perform a task on. | 5.5 5.6 7.0 7.1 7.2 7.3 7.4 |
Any combination from 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 |
PHP_VARIANTS |
Space separated list of Docker build variants to perform a task on | cli fpm |
cli, fpm |
BIN_DIR |
Directory in your PATH where you would like to symlink the scripts |
/usr/local/bin |
Any path on your system. Preferaby one already in your PATH |
SCRIPTS_DIR |
Directory where the scripts are generated (or removed). Relative to the repository's root | scripts |
Any path on your system |
Note: When overriding space separated values from the CLI, you have to escape spaces. For example in
bashyou can use\or wrap your values in":$ make build PHP_VERSIONS=7.0\ 7.1\ 7.2\ 7.3\ 7.4 PHP_VARIANTS=cli\ fpm # or $ make build PHP_VERSIONS="7.0 7.1 7.2 7.3 7.4" PHP_VARIANTS="cli fpm"
Locally builds all images from all possible combinations of PHP_VERSIONS and PHP_VARIANTS. SOURCE_BRANCH is appended to the image name. The DOCKER_TAG is used to target a specific PHP version and variant.
Command:
$ make build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [DOCKER_TAG=] [DOCKER_REPO=] [DOCKER_TAG=]Remove all locally cached images from all possible combinations of PHP_VERSIONS and PHP_VARIANTS. The DOCKER_TAG is used to target a specific PHP version, variant.
Command:
$ make rm_build [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [DOCKER_TAG=] [DOCKER_REPO=]Alias for removing then building the images: make rm_build build.
Generate the bash scripts from templates in the template directory. Generated scripts are saved in the SCRIPTS_DIR directory. The PHP_VERSION PHP_VARIANT and SOURCE_BRANCH are passed to the templates.
Command:
This task first runs: rm_scripts_dir
$ make scripts [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [SCRIPTS_DIR=]Removes the SCRIPTS_DIR directory.
Command:
$ make rm_scripts_dir [SCRIPTS_DIR=]Note: Linux and Mac OS only
This task creates symlinks of the scripts inside of SCRIPTS_DIR inside of the BIN_DIR. This adds them to your PATH environment variable (Linux and Mac OS only) easily making them available for use on your command line.
Command:
$ make shortcuts [SCRIPTS_DIR=] [BIN_DIR=]Before run: make scripts
This task removes this repository's scripts' symlinks from the BIN_DIR.
Command:
$ make rm_shortcuts [PHP_VERSIONS=] [PHP_VARIANTS=] [BIN_DIR=]Pushes the images to Dockerhub.
Truly, only used when developing to make sure that the Autobuild
post_pushhook works properly.
Command:
make post_push [PHP_VERSIONS=] [PHP_VARIANTS=] [SOURCE_BRANCH=] [DOCKER_TAG=] [DOCKER_REPO=]Warning: Running this task will remove any dangling volume and image on your system; not just the ones provided.
Command:
$ make rm_danglingMIT © Joseph Estefane