ddr / sonda
Line and branch coverage for PHP by instrumenting the source: much faster and lighter than Xdebug path coverage
Requires
- php: ^8.4
- nikic/php-parser: ^5.3
- phpunit/php-code-coverage: ^11.0 || ^12.0
- phpunit/phpunit: ^11.5 || ^12.0
Requires (Dev)
- illuminate/view: ^13
- laravel/pint: ^1.14
- pestphp/pest: ^3.8 || ^4.0
- pestphp/pest-plugin-arch: ^3.1 || ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- rector/rector: ^2.0
- sebastian/recursion-context: ^6.0.3 || ^7.0.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-31 02:08:33 UTC
README
Português · Documentation · Packagist
Line and branch coverage for PHP by instrumenting the source: no Xdebug, no PCOV, the suite runs at its normal speed, and every decision has to show both outcomes.
Sonda inserts probes into the code before loading it, the way Istanbul does for JavaScript. A probe
is one assignment into an array; there is no opcode interception and no path enumeration, which is
what makes Xdebug slow and heavy. On a Laravel suite of 4,514 tests: 178s without coverage, 174s
with Sonda, 671s with Xdebug counting lines only, and Xdebug with --path-coverage did not finish
in an hour. The numbers were validated against Xdebug path coverage on that whole suite.
Install
PHP 8.4+, PHPUnit 12 or Pest 4.
composer require --dev ddr/sonda
Use
vendor/bin/sonda test # the whole suite, the whole <source> of phpunit.xml vendor/bin/sonda test --changed=origin/master # only the files the branch changed; fails if any is left uncovered vendor/bin/sonda test --changed=origin/master --affected # and only the tests that execute them vendor/bin/sonda test --html=coverage/html --cobertura=coverage/cobertura.xml
Coverage: lines 12118/12118 (100.00%), branches 4857/4857 (100.00%)
Of what changed: lines 86/86 (100.00%), branches 31/31 (100.00%)
The changed files are 100% covered.
Branches are counted in a strict mode by default: an if without else needs both outcomes
tested, ?-> counts the null side, and &&/|| must short-circuit at least once. Blade views are
measured too, line and branch.
The documentation has the getting started guide, the CLI reference, the branch semantics, the comparison with Xdebug and recipes for GitLab and GitHub Actions.
Contributing
See CONTRIBUTING.md. Bug reports go to the
issues with the output of sonda --version.