spatie/laravel-horizon-watcher
Run Horizon locally with auto-restarts on code changes. Adds an artisan command horizon:watch that starts Horizon and restarts it whenever PHP (or configured) files are created, updated, or deleted—great for avoiding stale workers during development.
spatie/flysystem-event-handler or similar) to trigger restarts, which is lightweight but limited to PHP file changes (excludes config/environment changes).horizon:watch) with zero configuration required. Integration reduces to:
composer require spatie/laravel-horizon-watcher
php artisan horizon:watch
.env, config/horizon.php). No conflicts with other queue supervisors (e.g., Supervisor, systemd).node_modules). Mitigation: Exclude paths via Horizon’s ignore_files or custom event filtering..env checks, CI exclusions)?ignore_files or custom event handlers that could conflict?nodemon or entr + custom scripts achieve the same with more control?laravel/horizon)..env (QUEUE_CONNECTION=redis).composer require spatie/laravel-horizon-watcher --dev
php artisan horizon with:
php artisan horizon:watch
package.json scripts (optional):
"scripts": {
"dev:horizon": "php artisan horizon:watch"
}
ignore_files in config/horizon.php:
'ignore_files' => [
app_path('Horizon/IgnoredDirectory/*'),
storage_path('logs/*'),
],
inotify (Linux) or equivalent (macOS/Windows). Docker users may need --privileged or custom event handlers..env checks or script guards):
if [ "$APP_ENV" != "local" ]; then exit 0; fi
php artisan horizon:watch
horizon:watch → Verify auto-restarts.CONTRIBUTING.md or DEVELOPMENT.md.bin/local-setup).storage/logs/horizon-watcher.log (customizable).storage/logs/laravel.log for event triggers.inotify limits on Linux).horizon:watch on shared files (e.g., Docker volumes). Mitigation:
QUEUE_CONNECTION=redis-dev1).| Failure | Impact | Mitigation |
|---|---|---|
| Filesystem event failure | No restarts on file changes | Fallback to manual restarts or nodemon. |
| Horizon crash on restart | Job queue stalls | Check Horizon logs; exclude problematic files. |
| Docker/WSL event issues | Restarts don’t trigger | Use docker events or custom scripts. |
| Infinite restart loop | CPU/memory spikes | Add delay (e.g., sleep 2 in watcher). |
horizon with horizon:watch in your workflow."Ctrl+C + horizon").ignore_files.How can I help you explore Laravel packages today?