A Docker image for running PHP CLI tooling (Composer, PHPUnit, PHPStan, PHPCS, PHPBench, ...) against a project, without installing PHP locally.
The image expects the project to be mounted at /app. It has no entrypoint, so any command can
be run directly.
services:
cli:
image: ghcr.io/phppdf/docker-image-php-cli:dev
volumes:
- ./:/appdocker compose run --rm cli composer install
docker compose run --rm cli vendor/bin/phpunitBy default the image runs as a non-root user, app (UID/GID 1000), so files created inside the
container are owned by your user on the host (on most single-user Linux installations, the first
user is UID/GID 1000). If your UID/GID differs, override it with
docker compose run --rm --user "$(id -u):$(id -g)" cli ....
Run PHPUnit with coverage (the image includes Xdebug):
docker compose run --rm -e XDEBUG_MODE=coverage cli vendor/bin/phpunit --coverage-html .phpunit-coverage