phpunit-watcher
phpunit-watcher is a PHP development tool that automatically reruns PHPUnit tests whenever source code changes, eliminating the manual rerun step during test-driven development. It supports global or local installation, custom watch directories, desktop notifications, and PHPUnit argument passthrough for flexible test filtering.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | spatie/phpunit-watcher |
| Owner | spatie |
| Primary language | PHP |
| License | MIT — OSI-approved |
| Stars | 875 |
| Forks | 76 |
| Open issues | 0 |
| Latest release | 1.24.4 (2026-01-05) |
| Last updated | 2026-06-26 |
| Source | https://github.com/spatie/phpunit-watcher |
What phpunit-watcher is
A Composer-installable CLI utility that monitors specified directories (src, tests by default) for file modifications and triggers PHPUnit test execution via a configured binary path. Uses Symfony Finder component for file monitoring, supports YAML configuration for watch patterns and PHPUnit arguments, and provides interactive keyboard commands for test control.
Get the phpunit-watcher source
Clone the repository and explore it locally.
git clone https://github.com/spatie/phpunit-watcher.gitcd phpunit-watcher# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Install globally via `composer global require spatie/phpunit-watcher` for project-agnostic use, or locally as `--dev` dependency to keep version control consistent across team members.
- Create a `.phpunit-watcher.yml` configuration file in the project root to customize watched directories, file masks, and PHPUnit binary paths; the tool searches parent directories for config inheritance.
- On Unix/Linux/macOS, use Composer script helpers with input redirection (`< /dev/tty`) and disabled process timeout to ensure interactive commands work correctly when invoked via `composer run`.
- Optimize performance on large repositories by excluding non-essential directories (e.g., vendor, node_modules) and enabling VCS ignore filters (`ignoreVCS: true`) in the YAML config.
- Verify PHPUnit binary path matches your project structure; default assumes `vendor/bin/phpunit`, but custom paths (e.g., `./vendor/phpunit/phpunit/phpunit`) may be required.
When to avoid it — and what to weigh
- Large Codebases with Slow Test Suites — If test execution takes >30 seconds per run, frequent reruns may create I/O bottlenecks and hinder developer productivity rather than improve it; consider test parallelization or segmentation first.
- Windows Development Without TTY Support — Interactive command features (e.g., filtering tests mid-run) are disabled on Windows; users must provide all PHPUnit arguments upfront, limiting real-time test control.
- CI/CD or Headless Server Environments — This tool is designed for interactive local development; it is not suitable for automated pipelines, containers, or environments where human keyboard input cannot be provided.
- Projects Requiring Strict Process Isolation — If your testing strategy mandates complete test process restart between runs (e.g., for state cleanup), continuous rerun behavior may introduce false positives or state leakage.
License & commercial use
Licensed under the MIT License (MIT). Permits unrestricted commercial and private use, modification, and distribution provided the license notice is retained. Standard OSI-approved permissive license.
MIT license explicitly permits commercial use. No licensing restrictions documented for business deployments. No commercial licensing tier mentioned; free use is clear.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Tool executes PHPUnit binary as configured; ensure the binary path and watched directories are controlled and validated. Security contact ([email protected]) is provided for vulnerability reporting. No specific OWASP-class vulnerabilities or exploitation details documented. File monitoring relies on OS-level file system APIs; no custom encryption or authentication is employed.
Alternatives to consider
Jest (JavaScript/Node.js equivalent)
Offers similar test-watch functionality with interactive commands, snapshots, and better support for monorepos. Mentioned as inspiration in phpunit-watcher credits but targets different ecosystem.
PHPSpec with watch plugins
Behavior-driven development alternative with third-party watch support. Targets specification-first workflows; lighter learning curve for non-TDD teams but smaller ecosystem.
Manual PHPUnit + shell script/Makefile
Zero-dependency approach using `inotifywait` (Linux) or `entr` (macOS) to trigger PHPUnit. More control but requires custom scripting and OS-specific tooling.
Build on phpunit-watcher with DEV.co software developers
Reduce friction in your testing workflow. Install phpunit-watcher today and get instant feedback as you code. MIT-licensed, production-ready, and actively maintained.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
phpunit-watcher FAQ
Can I run phpunit-watcher in CI/CD pipelines?
How do I exclude vendor or other large directories from being watched?
Does phpunit-watcher support Windows?
What if my tests take a long time to run?
Custom software development services
Need help beyond evaluating phpunit-watcher? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source testing integrations — and maintain them long-term.
Accelerate Your PHP Test-Driven Development
Reduce friction in your testing workflow. Install phpunit-watcher today and get instant feedback as you code. MIT-licensed, production-ready, and actively maintained.