Download the PHP package matthiasnoback/live-code-coverage without Composer
On this page you can find all versions of the php package matthiasnoback/live-code-coverage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matthiasnoback/live-code-coverage
More information about matthiasnoback/live-code-coverage
Files in matthiasnoback/live-code-coverage
Package live-code-coverage
Short Description Generate code coverage reports on a live server
License MIT
Informations about the package live-code-coverage
Live code coverage
This library should help you generate code coverage reports on a live server (it doesn't have to be a production server of course).
Install this library using:
Collecting code coverage data
In your front controller (e.g. index.php
), add the following:
- The first argument passed to
LiveCodeCoverage::bootstrap()
is a boolean that will be used to determine if code coverage is enabled at all. The example shows how you can use an environment variable for that. - The second argument is the directory where all the collected coverage data will be stored (
*.cov
files). If this directory doesn't exist yet, it will be created. - The third argument is the path to a PHPUnit configuration file. Its
<filter>
section will be used to configure the code coverage whitelist. For example, thisphpunit.xml.dist
file might look something like this:
Most configuration directives that are available in PHPUnit work for this library too. If you notice that something doesn't work, please submit an issue.
If you don't provide a PHPUnit configuration file, no filters will be applied, so you will get a coverage report for all the code in your project, including vendor and test code if applicable.
If your application is a legacy application which exit()
s or die()
s before execution reaches the end of your front controller, the bootstrap should be slightly different:
Generating code coverage reports (HTML, Clover, etc.)
To merge all the coverage data and generate a report for it, install Sebastian Bergmann's phpcov
tool. Run it like this (or in any other way you like):
Downsides
Please note that collecting code coverage data will make your application run much slower. Just see for yourself if that's acceptable.
All versions of live-code-coverage with dependencies
webmozart/assert Version ^1.2
phpunit/php-code-coverage Version ^9.0
phpunit/phpunit Version ^9.3