php-coveralls
Submit PHP code coverage reports to Coveralls
TLDR
Send coverage information to Coveralls
Send coverage information to Coveralls for a specific directory
Send coverage information to Coveralls with a specific config
Send coverage information to Coveralls with verbose output
Send coverage information to Coveralls excluding source files with no executable statements
Send coverage information to Coveralls with a specific environment name
Specify multiple Coverage Clover XML files to upload
Output the JSON that will be sent to Coveralls to a specific file
SYNOPSIS
php-coveralls [OPTIONS] <INPUT_FILE>
php-coveralls --clover <CLOVER_XML_FILE>
php-coveralls --json <JSON_FILE>
php-coveralls --coverage-bin <COVERAGE_BIN_FILE>
PARAMETERS
--clover
Specifies the path to the Clover XML coverage report file generated by PHPUnit.
--json
Specifies the path to a JSON coverage report file.
--coverage-bin
Specifies the path to a serialized php-code-coverage data file.
--config-file
Specifies an alternative path to the .coveralls.yml configuration file.
--root-dir
Sets the base directory for file paths in the coverage report.
--exclude-no-stmt
Excludes files from the report that contain no executable statements.
--dry-run
Prevents the actual submission of data to Coveralls.io; useful for testing.
--verbose
Enables verbose output, showing detailed processing information.
--version
Displays the version of php-coveralls.
--help
Displays the help message and available options.
DESCRIPTION
php-coveralls is a command-line utility designed to integrate PHP code coverage data with the Coveralls.io service. Coveralls.io is a web-based platform that tracks and visualizes code coverage over time, helping developers maintain and improve code quality.
This tool acts as a bridge, taking coverage reports generated by PHPUnit (typically in Clover XML format) or other PHP coverage tools, processing them, and then submitting them to Coveralls.io. It's most commonly employed in Continuous Integration (CI) environments, such as Travis CI, CircleCI, or GitHub Actions. After running automated tests and generating a coverage report, php-coveralls is executed to upload this data.
This allows teams to immediately see the impact of new code on overall test coverage, identify untested areas, and enforce coverage thresholds. The tool handles the conversion of various coverage formats into the Coveralls.io-compatible JSON format, and it automatically detects CI environment variables to associate reports with specific builds, branches, and pull requests. By providing historical coverage trends and per-file/per-line coverage details, php-coveralls significantly enhances visibility into the test suite's effectiveness, promoting better development practices and ensuring robust applications.
CAVEATS
php-coveralls relies on external tools (like PHPUnit) to generate the initial coverage reports. Ensure these tools are correctly configured and producing valid output in a supported format (Clover XML, JSON, or php-code-coverage binary).
Network connectivity is required to send data to Coveralls.io. Environment variables for CI services (e.g., CI_NAME, CI_BUILD_NUMBER) are crucial for proper report attribution on Coveralls.io.
TYPICAL USAGE WORKFLOW
1. Install php-coveralls: Use Composer: composer require --dev satooshi/php-coveralls.
2. Configure PHPUnit for coverage: Ensure phpunit.xml is set up to generate a Clover XML report (e.g.,
3. Run tests and generate coverage: Execute PHPUnit: vendor/bin/phpunit --coverage-clover build/logs/clover.xml.
4. Submit to Coveralls.io: Run php-coveralls: vendor/bin/php-coveralls --clover=build/logs/clover.xml -v.
5. CI Integration: Configure your CI service (e.g., Travis CI, GitHub Actions) to run steps 3 and 4 after a successful build. Ensure the COVERALLS_REPO_TOKEN environment variable is set in your CI environment for private repositories.
HISTORY
php-coveralls was created to address the need for a PHP-specific client to integrate with the Coveralls.io service, similar to existing clients for Ruby, Python, and JavaScript. Its development has focused on supporting various PHP code coverage formats and seamlessly integrating with popular CI/CD platforms, making it a staple for PHP projects aiming for continuous code quality monitoring.