Docs
Code coverage
The image bundles Xdebug, which is the easiest way to collect code
coverage with PHPUnit. Xdebug’s coverage mode adds overhead, so it is disabled by default and must
be enabled per-run via the XDEBUG_MODE environment variable.
Running PHPUnit with coverage
docker run --rm -v ./:/app -e XDEBUG_MODE=coverage \
ghcr.io/phppdf/docker-image-php-cli:dev \
vendor/bin/phpunit --coverage-html .phpunit-coverage
With Compose:
docker compose run --rm -e XDEBUG_MODE=coverage cli \
vendor/bin/phpunit --coverage-html .phpunit-coverage
The HTML report is written to .phpunit-coverage/ in the project, since /app is a bind mount of
the project directory.
Other coverage formats
Any PHPUnit coverage option works the same way, for example a text summary on stdout:
docker run --rm -v ./:/app -e XDEBUG_MODE=coverage \
ghcr.io/phppdf/docker-image-php-cli:dev \
vendor/bin/phpunit --coverage-text