PHP Docker images for development and CI, built on top of php:<version>-cli-alpine.
Published to ghcr.io/phpyh/php for linux/amd64 and linux/arm64 on every push to main and every Monday,
so PHP patch releases, extensions and tools stay up to date.
| Tag | PHP |
|---|---|
ghcr.io/phpyh/php:8.2 |
8.2 (no updates after security EOL on 31 Dec 2026) |
ghcr.io/phpyh/php:8.3 |
8.3 |
ghcr.io/phpyh/php:8.4 |
8.4 |
ghcr.io/phpyh/php:8.5 |
8.5 |
ghcr.io/phpyh/php:8.6 |
8.6 (RC until GA release) |
Each image is also tagged with the full PHP version, e.g. ghcr.io/phpyh/php:8.5.12.
Both tags are moving: they are rebuilt weekly with the latest extensions and tools.
For a reproducible environment, pin the image by digest:
image: ghcr.io/phpyh/php:8.5@sha256:<digest>Get the current digest with docker buildx imagetools inspect ghcr.io/phpyh/php:8.5.
Notable changes, including breaking ones, are listed in CHANGELOG.md.
# compose.yaml
services:
app:
image: ghcr.io/phpyh/php:8.5
volumes:
- .:/app
- composer-cache:/composer/cache
working_dir: /app
volumes:
composer-cache:Or as a one-off command:
docker run --rm -it -v "$PWD:/app" -w /app ghcr.io/phpyh/php:8.5 composer installThe container runs as dev with UID 1000, the UID of the first user on most Linux systems.
On Linux, bind-mounted files keep their numeric owner, so if your UID is different (id -u),
the container can't write to your project. Run it as your host user then: user: <uid>:<gid> in Compose
or -u "$(id -u):$(id -g)" with docker run. Composer home, Composer cache and the Xdebug log are writable by any user.
Such a user has no /etc/passwd entry, so HOME is / and git config --global is not available.
On macOS and Windows, Docker Desktop remembers the owner of files created in the container, and a container running with another UID can't modify them. Always run the container with the same UID.
Mount a named volume to /composer/cache to keep the cache between runs, as in the example above.
To bind-mount a host directory instead, create it first, otherwise Docker creates it owned by root.
make,gitandunzipLC_ALL=C.UTF-8, so CLI tools and PHP handle UTF-8 correctly- User
devwith UID/GID1000, see File permissions - Git trusts all directories (
safe.directory=*), so it works in mounted repositories owned by another user - PHP extensions:
bcmath,ev,event(withsocketssupport),intl,mbstring,opcache,pcntl,pdo_pgsql,pgsql,sockets,uvandxdebug(off by default, see Xdebug) - Composer with a short alias
c.COMPOSER_HOMEis/composerand is writable by any user,/composer/vendor/binis appended toPATH, so global tools run by name and never shadow system binaries - Quality tools as global Composer packages:
Drop any .ini file into /usr/local/etc/php/conf.d/ — PHP picks it up automatically.
Via a volume mount:
services:
app:
image: ghcr.io/phpyh/php:8.5
volumes:
- ./php.ini:/usr/local/etc/php/conf.d/99-local.iniOr by extending the image:
FROM ghcr.io/phpyh/php:8.5
COPY php.ini /usr/local/etc/php/conf.d/99-local.iniXdebug is installed, but disabled by default (xdebug.mode=off), so it doesn't slow PHP down.
Enable it for a single run with the XDEBUG_MODE environment variable:
# Code coverage
docker compose run --rm -e XDEBUG_MODE=coverage app vendor/bin/phpunit --coverage-html=var/coverage
# Step debugging of a CLI script
docker compose run --rm -e XDEBUG_MODE=debug -e XDEBUG_TRIGGER=1 app php script.phpAdd to the service from Usage:
# compose.yaml
services:
app:
environment:
# Must match the server name in PhpStorm (Settings → PHP → Servers) with path mappings for /app
PHP_IDE_CONFIG: serverName=app
extra_hosts:
# Required on Linux only: Docker Desktop resolves host.docker.internal on its own
- host.docker.internal:host-gatewayXdebug connects to host.docker.internal:9003. If the IDE doesn't receive a connection, check /xdebug.log in the container.
MIT License — see LICENSE for details.