composer require --dev php-coveralls/php-coveralls
phpunit.xml to generate a clover.xml report:
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
.travis.yml):
after_success:
- php vendor/bin/php-coveralls -v
.coveralls.yml (if not using CI):
repo_token: your_coveralls_token
service_name: travis-pro
coverage_clover: build/logs/clover.xml
Run tests locally with coverage:
phpunit --coverage-clover build/logs/clover.xml
Then upload to Coveralls:
php vendor/bin/php-coveralls
CI Integration
after_success in GitHub Actions, GitLab CI, or CircleCI to trigger Coveralls upload.- name: Upload to Coveralls
run: php vendor/bin/php-coveralls -v
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
Local Development
COVERALLS_RUN_LOCALLY=1 and COVERALLS_REPO_TOKEN to test locally:
export COVERALLS_RUN_LOCALLY=1
export COVERALLS_REPO_TOKEN=your_token
php vendor/bin/php-coveralls
Parallel Testing
clover.xml files using phpcov (as shown in README) before uploading:
php vendor/bin/phpcov merge --clover build/logs/clover.xml build/cov
php vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml
Custom Configuration
.coveralls.yml or CLI flags:
php vendor/bin/php-coveralls --json_path=custom/path.json --env=dev
phpunit.xml is configured for coverage-clover in Laravel’s test suite.clover.xml via pest.php:
tests()->coverage()->outputTo('build/logs/clover.xml');
Token Security
repo_token in .coveralls.yml; use environment variables or CI secrets..env.coveralls (add to .gitignore):
COVERALLS_REPO_TOKEN=your_token
Path Issues
clover.xml paths in .coveralls.yml are relative to the project root.--root_dir to override the assumed root directory:
php vendor/bin/php-coveralls --root_dir=/path/to/project
CI-Specific Quirks
travis_retry to avoid flaky uploads.vendor/ to speed up builds:
- uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Windows Compatibility
.coveralls.yml must use forward slashes (/), even on Windows.-v to debug upload issues:
php vendor/bin/php-coveralls -v
php vendor/bin/php-coveralls --dry-run
php vendor/bin/php-coveralls --exclude-no-stmt
Custom API Endpoint
# .coveralls.yml
entry_point: https://your-coveralls-instance.com
Post-Processing
coveralls-upload.json to customize data before upload (e.g., filter tests).Symfony Integration
symfony/console integration for Laravel Artisan commands:
use Symfony\Component\Console\Application;
$app = new Application();
$app->add(new \Coveralls\Command\CoverallsCommand());
$app->run();
How can I help you explore Laravel packages today?