This repository contains a set of developer-friendly, general purpose PHP images for Docker.
- You can enable or disable the extensions using environment variables.
- You can also modify the
php.inisettings using environment variables. - 2 types available:
slim(no extensions preloaded) orfat(most common PHP extensions are built-in) - 3 variants available:
CLI,apacheandfpm - Fat images are bundled with Supercronic which is a Cron compatible task runner. Cron jobs can be configured using environment variables
- All images come with Composer installed
- All variants can be installed with or without NodeJS (if you need to build your static assets).
- Composer binaries (
vendor/binand global binaries) and NodeJS binaries (node_modules/.bin) can be run without their path, including withdocker exec/docker compose exec(e.g.docker compose exec app phpstan) - Everything is done to limit file permission issues that often arise when using Docker. The image is actively tested on Linux, Windows and MacOS
See the documentation for all the features.
Note: we also tag patch releases of PHP versions. So you can specify a specific patch release using thecodingmachine/php:8.4.1-v5-cli for instance. However, unless you have a very specific need (for instance if the latest patch release of PHP introduced regressions), believe you have no valid reason to ask explicitly for 8.4.1 for instance. When 8.4.2 is out, you certainly want to upgrade automatically to this patch release since patch releases contain only bugfixes. Also, we automatically rebuild X.Y images every week, but only the latest X.Y.Z patch release gets a rebuild. The other patch releases are frozen in time and will contain bugs and security issues. So use those with great care.
[Major].[minor] images are automatically updated when a new patch version of PHP is released, so the PHP 8.4 image will always contain the most up-to-date version of the PHP 8.4.x branch.
We only maintain the PHP and NodeJS versions that are still supported by their respective communities (see PHP supported versions and NodeJS releases). Bugs are fixed on maintained versions only.
| PHP version | Status |
|---|---|
| 8.5 | Maintained (until 2029-12-31) |
| 8.4 | Maintained (until 2028-12-31) |
| 8.3 | Maintained (until 2027-12-31) |
| 8.2 | Maintained (until 2026-12-31) |
| 8.1 | Not maintained (end of life: 2025-12-31) |
| 8.0 | Not maintained (end of life: 2023-11-26) |
| 7.4 | Not maintained (end of life: 2022-11-28) |
| NodeJS version | Status |
|---|---|
| 26 | Maintained (until 2029-04-30) |
| 24 | Maintained (until 2028-04-30) |
| 22 | Maintained (until 2027-04-30) |
| 20 | Not maintained (end of life: 2026-04-30) |
Images of non-maintained versions are still available but no longer receive fixes: use them at your own risk and plan your upgrade.
The images are based on Ubuntu 24.04, with PHP from the ondrej/php repository.
Example with CLI:
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.4-v5-cli php your-script.phpExample with Apache:
$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-apacheExample with PHP-FPM:
$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-fpmExample with Apache + Node 24.x in a Dockerfile:
Dockerfile
FROM thecodingmachine/php:8.4-v5-apache-node24
COPY src/ /var/www/html/
RUN composer install
RUN npm install
RUN npm run buildMost features are configured with environment variables:
| Topic | Content | Main variables |
|---|---|---|
| PHP extensions | Extensions of the slim and fat images, enabling them, compiling them in a slim image | PHP_EXTENSION_*, PHP_EXTENSIONS |
| PHP configuration | Base php.ini file and php.ini parameters |
TEMPLATE_PHP_INI, PHP_INI_* |
| Variants | cli, apache (document root, ports, modules, user) and fpm | APACHE_DOCUMENT_ROOT, APACHE_HTTP_PORT, APACHE_EXTENSION_* |
| Processes | Startup commands, cron jobs and daemons run along with the main command | STARTUP_COMMAND_*, CRON_*, DAEMON_* |
| Debugging and profiling | Xdebug and Blackfire | PHP_EXTENSION_XDEBUG, XDEBUG_CLIENT_HOST, BLACKFIRE_AGENT |
| Advanced features | Permissions, NodeJS, Composer version, locales, SSH keys, Kubernetes | DOCKER_USER, COMPOSER_VERSION, LOCALES |
The slim images install some tools during the build of your image with an ARG before the FROM: PHP_EXTENSIONS,
INSTALL_CRON, INSTALL_LOCALES, NODE_VERSION and COMPOSER_VERSION.
Check the migration notes.
The Dockerfiles and this README are generated from the templates of the utils directory: see the
contributing guide to edit, build and test the images.
These images have been strongly inspired by tetraweb/php.