Download the PHP package faisalmirza/diff-coverage without Composer

On this page you can find all versions of the php package faisalmirza/diff-coverage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package diff-coverage

diff-coverage

Latest Version PHP Version License

Ensure new code is tested. Check coverage for only the lines you changed.


diff-coverage runs your tests with coverage and validates that changed lines meet your coverage threshold. Stop debating overall coverage percentages—focus on what matters: new code should be tested.

Why diff-coverage?

Traditional Coverage Diff Coverage
"We need 80% overall coverage" "New code must be tested"
Legacy code drags down metrics Only measures what you changed
Hard to improve incrementally Every PR can pass
Debates about thresholds Clear, actionable feedback

Requirements

Installation

Note: If not yet on Packagist, install from GitHub:

Quick Start

For Laravel, Pest, or PHPUnit projects, just run:

The tool auto-detects your test framework and runs tests with coverage automatically.

Configuration

Configuration is loaded in layers (each layer overrides the previous):

Option 1: Zero Configuration (Recommended)

diff-coverage auto-detects your project type and enables parallel testing if paratest is installed:

Framework Detection Source Path Coverage Path
Laravel artisan file app, src tests/coverage/clover.xml
Symfony bin/console + composer.json src var/coverage/clover.xml
CakePHP bin/cake file src tmp/coverage/clover.xml
CodeIgniter spark file app build/coverage/clover.xml
Yii yii file src tests/coverage/clover.xml
Laminas config/application.config.php module, src data/coverage/clover.xml
Pest vendor/bin/pest src, app coverage/clover.xml
PHPUnit phpunit.xml or vendor/bin/phpunit src, app coverage/clover.xml

Parallel Testing: Automatically enabled when brianium/paratest is installed.

Option 2: Configuration File

Create .diff-coverage.json in your project root:

All fields are optional. Only specify what you want to override.

Field Type Default Description
branch string origin/main Branch to compare against
threshold integer 100 Minimum coverage percentage for changed lines
coverage_file string (auto-detected) Path to Clover XML coverage file
test_cmd string (auto-detected) Command to run tests with coverage
source_paths array ["app", "src"] Directories to check for freshness

Option 3: CLI Arguments

Override any setting via command line:

Option Description Example
-b, --branch Branch to compare -b origin/develop
-t, --threshold Coverage threshold -t 80
-c, --coverage Coverage file path -c build/coverage.xml
-T, --test-cmd Test command -T "phpunit --coverage-clover=cov.xml"
-f, --force Force re-run tests -f
-s, --skip-tests Use existing coverage -s
-h, --help Show help -h

Usage Examples

Performance

Freshness Detection

diff-coverage automatically skips running tests if your coverage file is newer than your source files. This speeds up repeated runs during development.

To always run tests: ./vendor/bin/diff-coverage -f

To never run tests: ./vendor/bin/diff-coverage -s

CI Integration

GitHub Actions

GitLab CI

Bitbucket Pipelines

Exit Codes

Code Meaning
0 Coverage meets threshold (or no changes detected)
1 Coverage below threshold, tests failed, or configuration error

How It Works

  1. Detect your test framework (Laravel/Pest/PHPUnit)
  2. Run tests with coverage (unless skipped or fresh)
  3. Generate git diff against the target branch
  4. Filter coverage report to only changed lines
  5. Calculate coverage percentage for those lines
  6. Exit with success/failure based on threshold

Under the hood, diff-coverage uses exussum12/coverage-checker for the diff filtering logic.

Troubleshooting

"No changes detected"

Your branch has no diff against the target branch. This is normal for the main branch.

"Coverage file not found"

Tests may have failed, or the coverage file path is incorrect. Check:

Coverage seems wrong

Ensure you're comparing against the correct branch:

Tests run every time

The freshness check compares timestamps. If your CI always clones fresh, tests will always run. This is expected behavior in CI.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License. See LICENSE for details.


All versions of diff-coverage with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
exussum12/coverage-checker Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package faisalmirza/diff-coverage contains the following files

Loading the files please wait ...