Chris@0: [![Latest Stable Version](https://poser.pugx.org/phpunit/php-code-coverage/v/stable.png)](https://packagist.org/packages/phpunit/php-code-coverage) Chris@0: [![Build Status](https://travis-ci.org/sebastianbergmann/php-code-coverage.svg?branch=master)](https://travis-ci.org/sebastianbergmann/php-code-coverage) Chris@0: Chris@0: # PHP_CodeCoverage Chris@0: Chris@0: **PHP_CodeCoverage** is a library that provides collection, processing, and rendering functionality for PHP code coverage information. Chris@0: Chris@0: ## Requirements Chris@0: Chris@0: PHP 5.3.3 is required but using the latest version of PHP is highly recommended Chris@0: Chris@0: ### PHP 5 Chris@0: Chris@0: [Xdebug](http://xdebug.org/) is the only source of raw code coverage data supported for PHP 5. Version 2.1.3 of Xdebug is required but using the latest version is highly recommended. Chris@0: Chris@0: ### PHP 7 Chris@0: Chris@0: [phpdbg](http://phpdbg.com/docs) is currently the only source of raw code coverage data supported for PHP 7. Once Xdebug has been updated for PHP 7 it, too, will be supported. Chris@0: Chris@0: ### HHVM Chris@0: Chris@0: A version of HHVM that implements the Xdebug API for code coverage (`xdebug_*_code_coverage()`) is required. Chris@0: Chris@0: ## Installation Chris@0: Chris@0: To add PHP_CodeCoverage as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-code-coverage` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHP_CodeCoverage 2.0: Chris@0: Chris@0: { Chris@0: "require": { Chris@0: "phpunit/php-code-coverage": "^2" Chris@0: } Chris@0: } Chris@0: Chris@0: ## Using the PHP_CodeCoverage API Chris@0: Chris@0: ```php Chris@0: start(''); Chris@0: Chris@0: // ... Chris@0: Chris@0: $coverage->stop(); Chris@0: Chris@0: $writer = new PHP_CodeCoverage_Report_Clover; Chris@0: $writer->process($coverage, '/tmp/clover.xml'); Chris@0: Chris@0: $writer = new PHP_CodeCoverage_Report_HTML; Chris@0: $writer->process($coverage, '/tmp/code-coverage-report'); Chris@0: ```