1[![Latest Stable Version](https://poser.pugx.org/phpunit/php-code-coverage/v/stable.png)](https://packagist.org/packages/phpunit/php-code-coverage) 2[![Build Status](https://travis-ci.org/sebastianbergmann/php-code-coverage.svg?branch=master)](https://travis-ci.org/sebastianbergmann/php-code-coverage) 3 4# PHP_CodeCoverage 5 6**PHP_CodeCoverage** is a library that provides collection, processing, and rendering functionality for PHP code coverage information. 7 8## Requirements 9 10PHP 5.6 is required but using the latest version of PHP is highly recommended. 11 12### PHP 5 13 14[Xdebug](http://xdebug.org/) is the only source of raw code coverage data supported for PHP 5. Version 2.2.1 of Xdebug is required but using the latest version is highly recommended. 15 16### PHP 7 17 18Version 2.4.0 (or later) of [Xdebug](http://xdebug.org/) as well as [phpdbg](http://phpdbg.com/docs) are supported sources of raw code coverage data for PHP 7. 19 20### HHVM 21 22A version of HHVM that implements the Xdebug API for code coverage (`xdebug_*_code_coverage()`) is required. 23 24## Installation 25 26You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): 27 28 composer require phpunit/php-code-coverage 29 30If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency: 31 32 composer require --dev phpunit/php-code-coverage 33 34## Using the PHP_CodeCoverage API 35 36```php 37<?php 38$coverage = new \SebastianBergmann\CodeCoverage\CodeCoverage; 39$coverage->start('<name of test>'); 40 41// ... 42 43$coverage->stop(); 44 45$writer = new \SebastianBergmann\CodeCoverage\Report\Clover; 46$writer->process($coverage, '/tmp/clover.xml'); 47 48$writer = new \SebastianBergmann\CodeCoverage\Report\Html\Facade; 49$writer->process($coverage, '/tmp/code-coverage-report'); 50``` 51 52