PHPackages                             phpunit/phpcov - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. phpunit/phpcov

ActiveLibrary[Testing &amp; Quality](/categories/testing)

phpunit/phpcov
==============

CLI frontend for php-code-coverage

12.0.0(3mo ago)23621.1M—2.3%5720BSD-3-ClausePHPPHP &gt;=8.4CI passing

Since Mar 7Pushed 1mo ago9 watchersCompare

[ Source](https://github.com/sebastianbergmann/phpcov)[ Packagist](https://packagist.org/packages/phpunit/phpcov)[ Docs](https://github.com/sebastianbergmann/phpcov)[ GitHub Sponsors](https://github.com/sebastianbergmann)[ RSS](/packages/phpunit-phpcov/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (36)Used By (20)

[![Latest Stable Version](https://camo.githubusercontent.com/bb29583394af8f7118337a014d67aacf762a0f69021d5eb967f905853cd16aea/68747470733a2f2f706f7365722e707567782e6f72672f706870756e69742f706870636f762f76)](https://packagist.org/packages/phpunit/phpcov)[![CI Status](https://github.com/sebastianbergmann/phpcov/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/phpcov/actions)[![codecov](https://camo.githubusercontent.com/c83d539757c1bb4d27ef6fd2fced25c08bcb6d32c4ec156b1e5401f2d9e827bb/68747470733a2f2f636f6465636f762e696f2f67682f73656261737469616e626572676d616e6e2f706870636f762f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/sebastianbergmann/phpcov)

phpcov
======

[](#phpcov)

**phpcov** is a command-line frontend for the php-code-coverage library.

Installation
------------

[](#installation)

This tool is distributed as a [PHP Archive (PHAR)](https://php.net/phar):

```
$ wget https://phar.phpunit.de/phpcov-X.Y.phar

$ php phpcov-X.Y.phar --version
```

Please replace `X.Y` with the version of PHPCOV you are interested in.

Using [Phive](https://phar.io/) is the recommended way for managing the tool dependencies of your project:

```
$ phive install phpcov

$ ./tools/phpcov --version

```

**[It is not recommended to use Composer to download and install this tool.](https://phpunit.readthedocs.io/en/11.0/installation.html#phar-or-composer)**

Usage
-----

[](#usage)

### Merging serialized code coverage data

[](#merging-serialized-code-coverage-data)

When you run PHPUnit with `--coverage-php`, it writes serialized code coverage data to a `.cov` file. The `phpcov merge` command merges multiple `.cov` files into a single code coverage report.

This is useful when you run test suites in parallel or across separate processes and want to combine the results into one report.

#### Example

[](#example)

Run your test suites separately, each writing their own `.cov` file:

```
$ phpunit --coverage-php /tmp/coverage/FooTest.cov tests/FooTest
$ phpunit --coverage-php /tmp/coverage/BarTest.cov tests/BarTest

```

Then merge the `.cov` files and generate a report:

```
$ phpcov merge --html /tmp/coverage-html /tmp/coverage

```

All `.cov` files in the specified directory will be merged.

You can generate reports in multiple formats at once:

```
$ phpcov merge --html /tmp/coverage-html --openclover /tmp/coverage.xml /tmp/coverage

```

#### Exporting merged data

[](#exporting-merged-data)

Use `--php` to write the merged coverage data back to a `.cov` file:

```
$ phpcov merge --php /tmp/merged.cov /tmp/coverage

```

#### Merging on a different machine

[](#merging-on-a-different-machine)

The serialized `.cov` files store file paths relative to a base path (the common path prefix of all covered files). When generating reports, the source files must be readable so that they can be analysed.

If you are merging `.cov` files on a different machine than where the tests were run, and the source code is located at a different path, use `--source` to specify where the source code is on the current machine:

```
$ phpcov merge --source /home/ci/project --html /tmp/coverage-html /tmp/coverage

```

#### Relaxing merge requirements

[](#relaxing-merge-requirements)

By default, `phpcov merge` requires that all `.cov` files were created using the same PHP version, the same code coverage driver, and (when present) the same Git state. If these do not match, the merge will fail.

You can relax these requirements with the following options:

OptionEffect`--do-not-require-matching-git-information`Allow merging files with different git state`--do-not-require-matching-php-version`Allow merging files from different PHP versions`--do-not-require-matching-code-coverage-driver`Allow merging files from different coverage driversFor example, to merge `.cov` files that were collected with different PHP versions:

```
$ phpcov merge --do-not-require-matching-php-version --html /tmp/coverage-html /tmp/coverage

```

#### Available Report Formats

[](#available-report-formats)

OptionFormat`--clover `Clover XML`--openclover `OpenClover XML`--cobertura `Cobertura XML`--crap4j `Crap4J XML`--html `HTML`--php `Serialized PHP (`.cov`)`--text `Plain text`--xml `PHPUnit XML### Patch Coverage

[](#patch-coverage)

The `phpcov patch-coverage` command calculates code coverage for the lines changed in a patch (unified diff). It reports how many of the changed executable lines are covered by tests.

#### Example

[](#example-1)

Generate a unified diff and collect code coverage:

```
$ git diff HEAD^1 > /tmp/patch.txt
$ phpunit --coverage-php /tmp/coverage.cov

```

Then calculate patch coverage:

```
$ phpcov patch-coverage /tmp/coverage.cov /tmp/patch.txt
1 / 2 changed executable lines covered (50.00%)

Changed executable lines that are not covered:

  Example.php:11

```

The command exits with code `0` when all changed executable lines are covered. It exits with `1` when some changed executable lines are not covered. It exits with `2` when no changed executable lines could be detected. This usually indicates a path mismatch.

#### The `--path-prefix` option

[](#the---path-prefix-option)

The `--path-prefix` option is needed when the file paths in the patch do not match the file paths in the coverage data.

The serialized `.cov` file stores file paths relative to a base path. The patch file contains paths relative to wherever `git diff` (or equivalent) was run. When both are relative to the same project root directory, which is the common case, they match and `--path-prefix` is not needed.

When the paths do not match, `--path-prefix` specifies the directory to prepend to the paths in the patch so that they can be resolved against the coverage data. For example, if the diff was generated from a parent directory and contains paths like `project/src/Foo.php`, but the coverage data has paths relative to the project root (`src/Foo.php`), you would use:

```
$ phpcov patch-coverage --path-prefix /path/to/project /tmp/coverage.cov /tmp/patch.txt

```

###  Health Score

77

—

ExcellentBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity67

Solid adoption and visibility

Community51

Growing community involvement

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~128 days

Recently: every ~63 days

Total

35

Last Release

101d ago

Major Versions

7.0.2 → 8.0.02020-08-11

8.2.1 → 9.0.02023-02-13

9.0.2 → 10.0.02024-02-02

10.0.1 → 11.0.02025-02-07

11.0.4 → 12.0.02026-02-06

PHP version history (12 changes)2.0.0PHP &gt;=5.3.3

3.0.0PHP &gt;=5.6

3.0.1PHP ^5.6 || ^7.0

4.0.0PHP ^7.0

5.0.0PHP ^7.1

6.0.0PHP ^7.2

7.0.0PHP ^7.3

8.2.0PHP &gt;=7.3

9.0.0PHP &gt;=8.1

10.0.0PHP &gt;=8.2

11.0.0PHP &gt;=8.3

12.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1089?v=4)[Sebastian Probst Eide](/maintainers/sebastian)[@sebastian](https://github.com/sebastian)

---

Top Contributors

[![sebastianbergmann](https://avatars.githubusercontent.com/u/25218?v=4)](https://github.com/sebastianbergmann "sebastianbergmann (373 commits)")[![webysther](https://avatars.githubusercontent.com/u/750007?v=4)](https://github.com/webysther "webysther (19 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (5 commits)")[![shrikeh](https://avatars.githubusercontent.com/u/445227?v=4)](https://github.com/shrikeh "shrikeh (3 commits)")[![adrienbrault](https://avatars.githubusercontent.com/u/611271?v=4)](https://github.com/adrienbrault "adrienbrault (2 commits)")[![bionda740](https://avatars.githubusercontent.com/u/71380556?v=4)](https://github.com/bionda740 "bionda740 (2 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (2 commits)")[![hpbuniat](https://avatars.githubusercontent.com/u/214626?v=4)](https://github.com/hpbuniat "hpbuniat (2 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (2 commits)")[![hnesk](https://avatars.githubusercontent.com/u/186821?v=4)](https://github.com/hnesk "hnesk (1 commits)")[![alexislefebvre](https://avatars.githubusercontent.com/u/2071331?v=4)](https://github.com/alexislefebvre "alexislefebvre (1 commits)")[![Jeroeny](https://avatars.githubusercontent.com/u/1517978?v=4)](https://github.com/Jeroeny "Jeroeny (1 commits)")[![kukulich](https://avatars.githubusercontent.com/u/260445?v=4)](https://github.com/kukulich "kukulich (1 commits)")[![NicolasCARPi](https://avatars.githubusercontent.com/u/3043706?v=4)](https://github.com/NicolasCARPi "NicolasCARPi (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![uyga](https://avatars.githubusercontent.com/u/5311267?v=4)](https://github.com/uyga "uyga (1 commits)")[![alexanderilyin](https://avatars.githubusercontent.com/u/272409?v=4)](https://github.com/alexanderilyin "alexanderilyin (1 commits)")[![sam-sandmann](https://avatars.githubusercontent.com/u/3257094?v=4)](https://github.com/sam-sandmann "sam-sandmann (1 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (1 commits)")

### Embed Badge

![Health badge](/badges/phpunit-phpcov/health.svg)

```
[![Health](https://phpackages.com/badges/phpunit-phpcov/health.svg)](https://phpackages.com/packages/phpunit-phpcov)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[codeception/codeception

All-in-one PHP Testing Framework

4.9k86.2M2.9k](/packages/codeception-codeception)[facile-it/paraunit

paraunit

146721.6k11](/packages/facile-it-paraunit)[innmind/black-box

Test library

44178.7k93](/packages/innmind-black-box)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
