About this project

php-code-coverage is a PHP library for collecting, processing, and rendering code coverage information. It is the coverage engine used by PHPUnit and can also be used standalone. Installation is done through Composer, either as a regular dependency or, more commonly, as a development-time dependency: composer require --dev phpunit/php-code-coverage The library exposes a CodeCoverage class that is constructed with a coverage driver and a filter. The filter defines which files should be included in coverage collection. A driver is selected via the Driver\Selector class, for example for line coverage. Coverage collection is bracketed by start() and stop() calls around the code under test. Reports can be generated in two ways. The first is directly from a CodeCoverage object using the Report\Facade, for example renderOpenClover() to write an OpenClover XML file. The second is from previously serialized coverage data: the Serialization\Unserializer reads a serialized coverage file, and ReportFacade::fromSerializedData() renders the desired report format from it. The README shows only the OpenClover rendering method in its examples, while the facade concept suggests additional report formats are available through other render methods. The project is maintained under the phpunit organization and is distributed via Packagist as phpunit/php-code-coverage. It is primarily relevant to PHP developers who need programmatic access to coverage data or who want to integrate coverage reporting into their own tooling.