spatie/phpunit-watcher
Automatically rerun PHPUnit tests whenever your code changes. Run phpunit-watcher watch to execute and re-execute tests on edits in app/src/tests. Supports passing through PHPUnit arguments (e.g. --filter) and works as a global tool or dev dependency.
Architecture fit: The package integrates seamlessly with Laravel's testing stack as it leverages PHPUnit directly, which is Laravel's default testing framework. It watches standard Laravel directories (app, tests, src) by default and requires no application code changes. Its event-driven architecture aligns with Laravel's development workflow for immediate feedback during TDD.
Integration feasibility: High feasibility. Installation is trivial via Composer (composer require --dev spatie/phpunit-watcher), and it works out-of-the-box with Laravel's directory structure. Configuration via YAML file allows customization of watched paths, PHPUnit arguments, and notifications without modifying project code.
Technical risk: Low overall risk but with specific considerations: Windows TTY support limitations (interactive commands disabled), potential performance degradation in monorepos without proper exclude configuration, and dependency versioning risks (e.g., Symfony 8 compatibility required recent patches). The package has no direct dependents but is actively maintained by Spatie with recent updates.
Key questions:
Stack fit: Native compatibility with Laravel's ecosystem. Uses Symfony components already present in Laravel (Finder, Console), ensuring no additional dependency conflicts. Works with all PHPUnit-based testing setups including Pest (via PHPUnit adapter).
Migration path: Minimal. Existing PHPUnit tests require no changes. Add to composer.json as dev dependency, create .phpunit-watcher.yml for customizations (e.g., exclude: [vendor, storage]), and define a Composer script: "test:watch": "phpunit-watcher watch". Team members can start using immediately after composer install.
Compatibility: Fully compatible with Laravel 8+ (PHP 8.1+). Recent versions (1.24.x) explicitly support Symfony 8 and PHP 8.2+. Avoids conflicts with Laravel's built-in test commands since it operates
How can I help you explore Laravel packages today?