spiral/roadrunner-jobs
Spiral RoadRunner Jobs driver and client for PHP. Run background tasks with RoadRunner’s jobs plugin, supporting queue configuration, message serialization, consuming and publishing jobs, and integrating into Spiral apps and workers for fast, reliable async processing.
composer require spiral/roadrunner-jobs.config/queue.php (or equivalent) to use roadrunner as the driver.jobs plugin enabled in your .rr.yaml or rr.yaml config (e.g., jobs: { pools: { default: { num_workers: 4, worker_options: { max_jobs: 10000 } } } }).php artisan roadrunner:reset (if using Spiral’s RoadRunner integration) or start RoadRunner via ./rr serve.MailJob::dispatch(...))—it’s consumed by a persistent RoadRunner worker instead of a short-lived PHP-FPM process.📌 Start here: Check the official RoadRunner docs for Laravel and inspect
spiral/roadrunner-jobs’config/queue.phpsnippet in the repo’s README.
dispatch(), dispatchNow(), or dispatchIf() as usual; roadrunner-jobs transparently intercepts the queue driver..rr.yaml to control concurrency, memory limits, and worker lifecycle:
jobs:
pools:
default:
num_workers: 4
worker_options:
max_jobs: 5000
memory_limit: 256M
pipeline: "default" # maps to a named pipeline config below
pipelines:
default:
route: default
priority: 0
default, emails, billing) by specifying the queue in your job’s viaQueue() method or dispatch(...)->onQueue('emails'). Configure topic mapping in .rr.yaml:
topics:
emails:
num_workers: 8
billing:
num_workers: 2
/metrics). Use container orchestration (Kubernetes, Docker Swarm) to scale worker replicas horizontally based on queue depth.FailedJobProvider—failed jobs are still stored in your configured failed_jobs table. RoadRunner handles retries within the worker via config (retry_until in worker_options).max_jobs or max_execution_time in .rr.yaml to restart workers gracefully. Tip: Monitor RR_WORKER_ID in logs to detect restarts.DB::reconnect() or DB::purge() in Job::finally() or handle() if long-running jobs risk stale connections.roadrunner:reset (via Laravel Horizon alternative) or send SIGHUP to the RoadRunner process to reload workers without downtime. Avoid kill -9.Spiral\RoadRunner\Jobs\JobHandlerInterface for custom job handling (e.g., for PSR-14 events or complex event sourcing).debug: true in .rr.yaml and check RoadRunner logs (stderr or logs/rr.log) for pipeline errors (e.g., {"level":"error","msg":"job failed","error":"class not found"}).How can I help you explore Laravel packages today?