laravel-jobs
Background jobs and event listeners for async processing. Use when working with queued jobs, background processing, events, or when user mentions jobs, queues, listeners, events, async processing.
When & Why to Use This Skill
This Claude skill provides expert guidance on implementing Laravel background jobs and event listeners using best-practice architectural patterns. It helps developers build scalable, asynchronous systems by delegating logic to actions, configuring robust queue systems, and managing complex job lifecycles including retries, timeouts, and middleware to ensure high performance and reliability.
Use Cases
- Case 1: Offloading time-consuming tasks such as image processing, PDF generation, or bulk email dispatching to background queues to maintain a responsive user interface.
- Case 2: Implementing event-driven architectures where system events (like 'OrderPlaced') trigger multiple decoupled listeners for inventory updates, shipping notifications, and CRM synchronization.
- Case 3: Managing high-reliability data imports or third-party API integrations using custom retry logic, exponential backoff, and job timeouts to handle transient failures gracefully.
- Case 4: Preventing race conditions and redundant processing in distributed systems by implementing unique jobs and custom job middleware for task-level locking.
| name | laravel-jobs |
|---|---|
| description | Background jobs and event listeners for async processing. Use when working with queued jobs, background processing, events, or when user mentions jobs, queues, listeners, events, async processing. |
Laravel Jobs
Background jobs and event listeners: thin delegation layers to actions.
Core Concept
jobs-listeners.md - Job patterns:
- Jobs as thin delegation layers
- Queue configuration
- Retry logic and timeouts
- Unique jobs
- Job middleware
- Event listeners
- When to use jobs vs sync actions
Pattern
final class ProcessOrderJob implements ShouldQueue
{
use Dispatchable, Queueable;
public function __construct(
public readonly int $orderId,
) {}
public function handle(ProcessOrderAction $action): void
{
$order = Order::findOrFail($this->orderId);
$action($order);
}
public function middleware(): array
{
return [new WithoutOverlapping($this->orderId)];
}
}
// Listener
final class SendOrderConfirmationListener
{
public function handle(OrderPlaced $event): void
{
SendOrderConfirmationJob::dispatch($event->order->id);
}
}
Jobs delegate to actions. Keep domain logic in actions, not jobs.