Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpspec Code Coverage Laravel Package

friends-of-phpspec/phpspec-code-coverage

PhpSpec extension that generates code coverage reports (console and HTML) for your specs. Works with Xdebug, phpdbg or pcov and supports multiple PhpSpec/PHP versions, helping you see which parts of your codebase are exercised by tests.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require --dev friends-of-phpspec/phpspec-code-coverage. Ensure PHP ≥ 8.1 (PHP 8.4 now supported) and Xdebug/PCOV is enabled. Enable coverage collection by adding --coverage to your phpspec run command (e.g., vendor/bin/phpspec run --coverage). Reports are generated in build/coverage by default (HTML, Clover, and PHP formats supported). Start with HTML report for quick visual feedback: open build/coverage/index.html in a browser after running tests.
Note: As of v7.0.0, Phpspec 8.0+ is required—older Phpspec versions are no longer supported.

Implementation Patterns

Use --coverage with CLI flags like --coverage-clover=build/coverage.xml for CI integration with tools like SonarQube or GitHub Actions. Combine with Phpspec’s config via phpspec.yml by defining extensions:

extensions:
  FriendsOf PhpSpec\CodeCoverage\CodeCoverageExtension: ~

To limit coverage to specific namespaces, use --coverage-filter=src/YourApp/ to avoid including tests or dependencies. For automation, add coverage steps in your CI workflow: run tests → generate report → upload to coverage service.
Note: Phpspec 8.0 compatibility is now enforced—ensure your phpspec/phpspec dependency is ^8.0 (check composer.json and composer.lock).

Gotchas and Tips

Coverage requires Xdebug or PCOV; ensure one is installed and enabled—coverage fails silently without it. Phpspec’s --stop-on-failure conflicts with full coverage runs; avoid mixing both. Breaking change: Extension is not auto-registered in Phpspec 8+—you must manually enable it via phpspec.yml. Coverage generation is slow on large suites; consider narrow filtering (--filter + --coverage-filter) during development. Check phpspec.yml for typos in extension class name (FriendsOf PhpSpec has a space—easy to miss). For better CI fidelity, combine with coverage-highlights to flag uncovered new code in PRs.
⚠️ Critical upgrade note: PHP < 8.1 is no longer supported. If your project uses PHP 8.0 or earlier, either upgrade PHP or pin to v6.x (if compatible).

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console