Download the PHP package harrisonratcliffe/laravel-queue-watch without Composer
On this page you can find all versions of the php package harrisonratcliffe/laravel-queue-watch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download harrisonratcliffe/laravel-queue-watch
More information about harrisonratcliffe/laravel-queue-watch
Files in harrisonratcliffe/laravel-queue-watch
Package laravel-queue-watch
Short Description Automatically restart your Laravel queue worker when application code changes, using pure-PHP polling โ no Node.js required.
License MIT
Homepage https://github.com/harrisonratcliffe/laravel-queue-watch
Informations about the package laravel-queue-watch
What it does
php artisan queue:watch runs queue:work as a long-lived child process and restarts it automatically whenever your application code changes โ so you get a production-like queue worker that picks up your edits without you stopping and starting it by hand.
That's the whole thing. Edit a job, save, and the worker is already running your new code.
๐ค Why polling?
Most file watchers โ including the Node/chokidar-based packages this one replaces โ rely on OS-level filesystem events like inotify. That works beautifully on bare metal. It's unreliable in the environment most Laravel developers actually use day to day: Docker on macOS or Windows, where your app runs in a Linux container over a bind-mounted volume from the host.
Host-side edits are frequently invisible to inotify inside the container, because the bind mount doesn't propagate native filesystem events across the VM boundary. The watcher doesn't error โ it just silently never fires.
Polling sidesteps this entirely:
- โ Doesn't care what kind of mount your code lives on
- โ
No
inotify/fswatchextension or binary required - โ Identical behaviour on macOS, Linux, Windows, and inside any container
Statting a few thousand files once a second is negligible overhead. In exchange you get a watcher that actually works everywhere, every time. That reliability โ not raw speed โ is this package's main advantage over the Node-based alternatives.
How it compares
queue:watch |
queue:listen |
Node-based watchers | |
|---|---|---|---|
| Requires Node/npm | โ No | โ No | โ Yes |
| Reloads code on change | โ Yes | โ Yes (every job) | โ Yes |
| Runs a persistent worker | โ Yes | โ No โ fresh process per job | โ Yes |
| Restart behaviour | Graceful โ SIGTERM, waits for the current job, then SIGKILL |
N/A | Package-dependent, often a hard kill |
| Reliable under Docker bind mounts | โ Yes (polling) | N/A | โ ๏ธ Often not (inotify) |
[!NOTE]
queue:listenalready reloads code on every job โ it just does so by booting the framework from scratch each time, which is the exact overheadqueue:workexists to avoid.queue:watchis for people who wantqueue:work's persistent, production-like execution model and automatic reloading on change.
๐ฆ Installation
Requirements: PHP 8.2+ and Laravel 11, 12, or 13.
That's it โ the package works out of the box with zero configuration.
To customise it, publish the config file:
๐ Usage
This starts queue:work and watches your application for changes, restarting the worker gracefully whenever it detects one.
Forwarded to queue:work
Common worker options are passed straight through to the underlying process:
| Option | Description |
|---|---|
--queue= |
Which queue(s) to process |
--connection= |
Which queue connection to use |
--timeout= |
Max seconds a child job may run |
--tries= |
Attempts before a job is failed |
--memory= |
Memory limit in megabytes |
--sleep= |
Seconds to sleep when no job is available |
Watcher options
| Option | Description |
|---|---|
--path=* |
Extra path to watch, merged with config (repeatable) |
--poll= |
Polling interval in milliseconds (default 1000) |
--extensions= |
Comma-separated extensions to watch (default php) |
--no-restart-on-env |
Don't watch .env for changes |
Examples:
โ๏ธ Configuration
[!TIP] Watching a large
resources/tree and finding restarts sluggish? Trimpathsdown to what actually affects your jobs โ usually justapp,config, and.env.
๐ก๏ธ Graceful restarts
Naively killing a queue worker to restart it is dangerous. A job can be mid-flight when the worker dies, and with a database queue driver that job then sits reserved until it times out, only to retry โ duplicating side effects if the original invocation had already partially completed.
queue:watch avoids this:
SIGTERMis sent to the worker.- Laravel's worker responds by finishing the job it's currently processing, then exiting cleanly.
- If it hasn't exited within
restart_timeoutseconds (default10), it's escalated toSIGKILL. - A fresh worker is spawned with your updated code.
[!WARNING] Windows limitation. POSIX signals need
ext-pcntl, which isn't available on Windows, so this graceful handshake isn't possible there โqueue:watchfalls back to a hard stop, the same asProcess::stop()would. A restart can therefore interrupt an in-flight job, and Ctrl+C won't get the chance to shut the worker down cleanly. WSL2 is strongly recommended on Windows.
When the worker exits on its own
If the worker dies by itself โ a crash, --max-jobs, or an internal queue:restart โ queue:watch reports the exit code and respawns it rather than hanging or exiting silently.
A worker that exits immediately is treated as a failure rather than a restart: repeated fast exits back off exponentially (250ms, doubling, capped at 10s) and queue:watch gives up after 10 in a row. This keeps a genuinely broken worker โ a bad worker_command, a missing artisan, a boot-time exception โ from being respawned in a tight loop that scrolls the underlying error out of view. Any worker that stays up for 5 seconds clears the streak.
๐งช Testing
Contributing
Contributions are welcome โ please see CONTRIBUTING for details.
Changelog
See CHANGELOG for what's changed recently.
Security
Please review our security policy on how to report security vulnerabilities.
Credits
- Harrison Ratcliffe
- All Contributors
License
The MIT License (MIT). Please see the License File for more information.
All versions of laravel-queue-watch with dependencies
illuminate/console Version ^11.0||^12.0||^13.0
illuminate/support Version ^11.0||^12.0||^13.0
symfony/process Version ^6.0||^7.0||^8.0