aureja/job-queue
JobQueue is a PHP package for managing job queues, providing a simple way to enqueue, process, and organize background tasks in your application. Suitable for basic queueing needs with a lightweight setup and straightforward API.
Queue facade and ShouldQueue jobs out of the box. Can replace Laravel’s default queue driver (e.g., sync, database) for custom logic.JobProcessed, JobFailed) and middleware hooks. Supports job payload serialization (JSON by default).queue:work or custom scripts).ShouldQueue jobs but needing lightweight, custom queue logic.Queue facade, events, and service container.SendEmailJob, ProcessPaymentJob) to identify queue dependencies.sync driver latency).sync) with JobQueue for a non-critical job type.database) if persistence is needed:
// Example: Custom Database Driver
class DatabaseJobQueueDriver implements JobQueueDriver {
public function push(Job $job) {
DB::table('job_queue')->insert([
'payload' => $job->payload,
'created_at' => now(),
]);
}
// ... other methods
}
config/queue.php to use JobQueue:
'default' => 'jobqueue',
'connections' => [
'jobqueue' => [
'driver' => 'jobqueue',
'options' => [
'max_jobs' => 100,
],
],
],
JobQueue events (e.g., JobProcessed).sync driver.delay() method) and chaining.queue:work or write a custom script:
php artisan queue:work --queue=jobqueue
sync driver for low-priority jobs (e.g., logging, notifications).JobProcessed/JobFailed events to a monitoring tool (e.g., Sentry, Datadog).max_jobs in config to control memory usage.JobQueue for simple jobs, Redis for high-throughput ones.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Server restart | Lost in-memory jobs | Use database driver or Redis |
| Worker crash | Unprocessed jobs | Implement a watchdog script |
| Job timeout | Stuck jobs | Add TTL to jobs or use queue:failed |
| Database failure (if used) | Jobs stuck in DB | Rebuild queue table or use migrations |
| Concurrency race conditions | Duplicate job processing | Add unique job IDs or use locks |
ShouldQueue and events.queue.php.php artisan queue:work.How can I help you explore Laravel packages today?