PHP_CodeCoverage
PHP_CodeCoverage is a free, open-source PHP library for collecting, processing, and rendering code coverage information.
What PHP_CodeCoverage is
PHP_CodeCoverage is a free, open-source PHP library for collecting, processing, and rendering code coverage information. It can be installed with Composer as a project dependency or as a development-only dependency. Coverage measures include lines, branches, paths, functions and methods, classes and traits, and the CRAP index. PCOV is suggested for line coverage, while Xdebug supports line, branch, and path data; PCOV provides line coverage only. Reports can be generated as HTML, Clover, OpenClover, Cobertura, Crap4J, PHPUnit XML, text, JSONL, or serialized PHP. HTML output includes directory and file views with line highlighting, plus class, trait, and function views grouped by namespace. Serialized files from separate runs can be merged with phpcov, and patch-coverage calculates coverage for changed lines in a unified diff. The library is a first-party PHPUnit dependency, follows PHPUnit’s security policy, and uses the BSD-3-Clause license. The current package requires PHP 8.4 or later and the DOM, libxml, mbstring, and xmlwriter extensions.
Good
- Supports line, branch, path, and other coverage metrics
- Produces HTML and several machine-readable report formats
- Merges serialized coverage from separate test runs
- Calculates coverage for changed diff lines
- Free under the BSD-3-Clause license
Watch out
- Requires PHP 8.4 or later
- Needs DOM, libxml, mbstring, and xmlwriter extensions
- PCOV only provides line coverage
- Branch and path coverage require Xdebug data
Who it suits
It suits PHP developers and teams that need coverage collection and report generation alongside PHPUnit. It is useful for projects requiring multiple coverage metrics, report formats, or changed-line analysis.
Verdict
PHP_CodeCoverage offers broad coverage metrics and output formats for PHP projects using PHPUnit. Check the PHP 8.4 requirement and choose Xdebug when branch or path coverage is needed.
The facts
Each one read from PHP_CodeCoverage's own pages, with the date it was checked.
What it does
- Coverage collection
- The usage example starts and stops coverage collection for a named test.checked 11 Oct 2026
- Coverage drivers
- The package suggests PCOV for line coverage and Xdebug for line, branch and path coverage.checked 4 Oct 2026
- Coverage limitation
- The PHPUnit manual says PCOV supports line coverage only; branch and path coverage require data collected with Xdebug.checked 4 Oct 2026
- Coverage metrics
- The PHPUnit manual says the library supports line, branch, path, function and method, class and trait coverage, and the CRAP index.checked 4 Oct 2026
- Development use
- The README recommends adding it as a development-time dependency when it is only needed to run a project's test suite.checked 11 Oct 2026
- HTML reports
- HTML reports provide directory and file views with line-by-line highlighting, plus class, trait and function views organized by namespace.checked 4 Oct 2026
- Installation
- The README shows installation as a per-project dependency with Composer.checked 11 Oct 2026
- Integration
- The repository describes the library as a first-party dependency of PHPUnit.checked 4 Oct 2026
- License
- The repository identifies the library's license as BSD-3-Clause.checked 11 Oct 2026
- Maintainer
- The Composer manifest names Sebastian Bergmann as the lead author.checked 11 Oct 2026
- Parallel runs
- Serialized coverage files from separate test runs can be merged with phpcov to produce a combined report.checked 4 Oct 2026
- Patch analysis
- The phpcov patch-coverage command calculates coverage for changed lines in a unified diff.checked 4 Oct 2026
- PHP requirement
- The Composer manifest requires PHP version 8.4 or later.checked 11 Oct 2026
- Purpose
- The library collects, processes, and renders PHP code coverage information.checked 11 Oct 2026
- Report formats
- The PHPUnit manual lists HTML, Clover, OpenClover, Cobertura, Crap4J, PHPUnit XML, text, JSONL and serialized PHP output.checked 4 Oct 2026
- Report output
- The example renders an OpenClover report from collected coverage data.checked 11 Oct 2026
- Runtime extensions
- The Composer manifest requires the DOM, libxml, mbstring, and xmlwriter PHP extensions.checked 11 Oct 2026
- Runtime requirements
- The current package requires PHP 8.4 or later and the DOM, libxml, mbstring and xmlwriter extensions.checked 4 Oct 2026
- Security policy coverage
- The project states that PHPUnit's security policy also applies to this library because it is a first-party PHPUnit dependency.checked 11 Oct 2026
- Security reporting
- The security policy asks vulnerability reporters to use coordinated disclosure and says not to report vulnerabilities through public GitHub issues, discussions, or pull requests.checked 11 Oct 2026
- Serialized data
- The README shows generating an OpenClover report from serialized coverage data using an unserializer.checked 11 Oct 2026
Alternatives to PHP_CodeCoverage
- 1

Codecov
Free planOpen sourceWebAPIExtensionLinux8.0From $5 a month - 2
Avidemux
Free planOpen sourceWebLinuxmacOSWindows7.3Free plan - 3
Coverage.py
Free planOpen sourceAPILinuxmacOSSelf-hosted7.3Free plan - 4

Coveralls
Free planWebAPILinuxSelf-hosted6.8From $10 a month - 5
ReportGenerator
Free planLinuxmacOSWindows6.8$79 one-time - 6
gcov
Free planLinuxmacOSWindows6.5Free plan
