- Why would I need pcov/clobber in a Laravel project?
- If your Laravel app (5.x–7.x) uses PHPUnit 5–7 and requires PCOV for code coverage but can’t upgrade due to void return type conflicts or third-party constraints, this package swaps Xdebug’s coverage driver with PCOV without modifying core Laravel code. It’s a temporary workaround for CI/CD pipelines or legacy systems.
- Does pcov/clobber work with Laravel’s built-in phpunit.xml?
- Yes, it operates at the PHPUnit layer, so it’s fully compatible with Laravel’s default phpunit.xml configuration. Just run `vendor/bin/pcov clobber` before tests and `unclobber` afterward if needed. No Laravel-specific changes are required.
- What Laravel versions support pcov/clobber?
- This package works with Laravel 5.8–8.x, as it targets PHPUnit 5–7. For Laravel 9+ (PHPUnit 8+), native PCOV support eliminates the need for this tool. If you’re on Laravel 5.x–7.x with PHPUnit 5–7, it’s a viable solution.
- How do I integrate pcov/clobber into my CI pipeline?
- Add `composer require pcov/clobber` to your dev dependencies, then run `vendor/bin/pcov clobber` before tests in your CI script (e.g., GitHub Actions, GitLab CI). Use `unclobber` post-test to revert changes. Example: `php vendor/bin/pcov clobber && phpunit --coverage-text && php vendor/bin/pcov unclobber`.
- Will this break parallel testing in Laravel?
- Parallel testing (e.g., `phpunit --parallel`) may fail if multiple processes try to clobber/unclobber simultaneously. Test in a staging environment first, or avoid parallel mode until you confirm compatibility. Race conditions are the primary risk.
- What if I already have Xdebug or PCOV extensions installed?
- The package assumes Xdebug is installed (versions 2.9–3.2) and will override its coverage driver. If you’re using custom Xdebug extensions or PCOV forks, conflicts may arise. Test thoroughly in a staging environment before production use.
- Can I use pcov/clobber with Laravel Testbench?
- Yes, since Testbench relies on PHPUnit, pcov/clobber will work seamlessly. Just ensure Testbench’s PHPUnit configuration isn’t overriding coverage drivers. Run `vendor/bin/pcov clobber` before Testbench tests as you would for regular Laravel tests.
- What’s the performance impact of using PCOV vs. Xdebug?
- PCOV is generally faster than Xdebug for coverage collection, but the overhead depends on your test suite size. Benchmark locally with `time vendor/bin/phpunit --coverage-text` before and after clobbering to compare. In CI, monitor runtime changes.
- Are there alternatives to pcov/clobber for Laravel?
- If you can upgrade to PHPUnit 8+, native PCOV support removes the need for this package. For Laravel 5–7, alternatives include manually configuring PCOV in phpunit.xml (if supported) or using Xdebug 3+ with PHPUnit 7.5+. However, these may not resolve void return type issues.
- How do I roll back if pcov/clobber corrupts my environment?
- Always run `vendor/bin/pcov unclobber` after tests to restore Xdebug. If issues persist, manually edit your PHPUnit configuration to revert coverage settings. Backup your original phpunit.xml or Xdebug config before clobbering for safety.