- How does spatie/laravel-horizon-watcher differ from manually restarting Horizon?
- Instead of manually running `php artisan horizon`, this package uses filesystem events to auto-restart Horizon whenever PHP files (e.g., jobs, workers, or config) change. It’s designed to save time during local development by eliminating the need to remember restarts after code updates.
- Will this work in production or only local environments?
- This package is **explicitly for local development only**. It’s not recommended for production due to the risk of abrupt worker terminations and potential state loss. Always exclude it from CI/CD pipelines or deployment scripts.
- Do I need to configure anything after installing via Composer?
- No configuration is required for basic usage. Just run `php artisan horizon:watch` to start Horizon with auto-restart on file changes. Optionally, publish the config to customize watched paths or ignored files.
- Can I use this with Laravel Horizon v4 or older?
- No, this package requires **Laravel Horizon v5.0+** due to dependency updates. If you’re on an older version, you’ll need to upgrade Horizon first or explore alternative solutions like custom watch scripts.
- What happens if my job is long-running or holds in-memory state?
- Auto-restarts may abruptly terminate workers, causing state loss (e.g., cached jobs or open connections). For stateful jobs, consider disabling the watcher or using Horizon’s `--once` flag for testing instead.
- How do I exclude certain directories (e.g., node_modules, IDE temp files) from triggering restarts?
- Use Horizon’s `ignore_files` configuration in `config/horizon.php` to exclude paths. For example, add `'ignore_files' => [storage_path('logs/*'), app_path('Temp/*')]` to prevent false restarts.
- Does this work inside Docker or WSL environments?
- Filesystem event detection may behave differently in Docker/WSL. Ensure volume mounts are properly configured, and test thoroughly. Some users report needing `--privileged` mode or custom event handlers for reliable behavior.
- Can I integrate this with Laravel Valet or Laravel Sail?
- Yes, it works seamlessly with Valet (auto-reload compatible) and Sail (if using Docker volumes). For Sail, ensure your `docker-compose.yml` mounts the correct paths for filesystem events to trigger.
- What if I’m not using Laravel Horizon but another queue system (e.g., RabbitMQ, SQS)?
- This package **only works with Laravel Horizon**. If you’re using raw Laravel queues or alternative systems, you’ll need a custom solution like `nodemon` or `entr` to monitor files and restart workers.
- How do I debug false restarts or missed file changes?
- Enable Horizon’s logging (`'logging' => true` in `config/horizon.php`) to track restarts. The package also logs filesystem events—check Laravel’s logs for details. For advanced debugging, extend the config to add custom event handlers.