Generic PHP
You don't need a framework to benefit from php-ci. For libraries, packages and plain applications, the base image gives you Composer 2 and the PHP extensions and system libraries commonly needed in CI.
Image tag
docker pull himanshuramavat/php-ci:8.3
A complete quality pipeline
Run tests, static analysis and a coding-standard check in one shot:
docker run --rm -v "$(pwd):/app" -w /app himanshuramavat/php-ci:8.3 bash -c '
composer install --no-interaction --prefer-dist &&
./vendor/bin/phpunit &&
./vendor/bin/phpstan analyse src --level=6 &&
./vendor/bin/phpcs --standard=PSR12 src
'
phpunit.xml for a library
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
failOnWarning="true"
failOnDeprecation="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Code coverage
The image includes a coverage driver, so you can produce reports directly:
docker run --rm -v "$(pwd):/app" -w /app himanshuramavat/php-ci:8.3 \
bash -c "composer install --no-interaction && \
./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml"
Suggested Composer scripts
{
"scripts": {
"test": "phpunit",
"analyse": "phpstan analyse src --level=6",
"cs": "phpcs --standard=PSR12 src",
"cs:fix": "phpcbf --standard=PSR12 src",
"ci": ["@cs", "@analyse", "@test"]
}
}
Your entire pipeline then becomes:
docker run --rm -v "$(pwd):/app" -w /app himanshuramavat/php-ci:8.3 \
bash -c "composer install --no-interaction && composer ci"
Testing a version matrix
For published packages, prove support across the whole range by reusing the same
commands against each tag — 8.1, 8.2, 8.3, 8.4. See the
GitHub Actions matrix for the
wiring.
Tools available
See Included Tools for the full list (PHPStan, PHP_CodeSniffer, php-cs-fixer, PHPUnit) and PHP Extensions for the loaded extensions.