Laravel queues
Skill fusengine/agents/plugins/laravel-expert/skills/laravel-queues
Laravel 13 background jobs - PHP Attributes (#[Queue], #[Connection], #[Tries], #[Backoff]), workers, batches, chains, middleware, Queue::route() centralised routing. Use for async tasks.From its SKILL.md
npx -y skills add fusengine/agents --skill laravel-queuesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.7 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
Laravel Queues (L13 — Attributes-first)
Agent Workflow (MANDATORY)
Before ANY implementation, use TeamCreate to spawn 3 agents:
- fuse-ai-pilot:explore-codebase - Audit job classes, connections, queue routes
- fuse-ai-pilot:research-expert - Verify L13 Queue + Queue::route() via Context7
- mcp__context7__query-docs - Check queue attribute patterns
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
Laravel 13 introduces PHP Attributes on Queueables (Jobs, Listeners, Notifications, Mailables, Broadcast Events) as the primary configuration mechanism. Centralised routing is configured via Queue::route() in AppServiceProvider::boot().
| Attribute (L13 MAIN) | Legacy property |
|---|---|
#[Connection('redis')] · #[Queue('podcasts')] | public $connection · public $queue |
#[Tries(5)] · #[Timeout(120)] · #[MaxExceptions(3)] | public int $tries / $timeout / $maxExceptions |
#[Backoff([10, 30, 60])] · #[FailOnTimeout] | public $backoff · public bool $failOnTimeout |
#[UniqueFor(3600)] · #[AfterCommit] · #[DeleteWhenMissingModels] | public $uniqueFor / $afterCommit / $deleteWhenMissingModels |
Applies to Jobs, Listeners, Notifications, Mailables, and Broadcast Events.
Critical Rules
- Declare queue metadata with Attributes -
#[Queue],#[Tries],#[Backoff] - Centralise routing with
Queue::route()inAppServiceProvider::boot() - Implement
failed(Throwable $e)for every production job - Use
#[AfterCommit]when dispatching inside DB transactions - Monitor Redis queues with Horizon in production
Architecture
app/
├── Jobs/
│ └── ProcessPodcast.php # #[Connection, Queue, Tries, Backoff]
├── Providers/
│ └── AppServiceProvider.php # Queue::route('podcasts', 'redis')
└── Listeners/
└── SendShipmentNotification.php # #[Queue('mail')]
→ See templates/QueueableJob.php.md
Reference Guide
Concepts
- Migration L12→L13: legacy-properties.md
- Jobs lifecycle: jobs.md · dispatching.md · workers.md
- Composition: batching.md · chaining.md · middleware.md
- Reliability: failed-jobs.md · horizon.md · testing.md · troubleshooting.md
Templates
| Template | When to Use |
|---|---|
| QueueableJob.php.md | Attribute-based job |
| BatchJob.php.md | Batchable job |
| ChainedJobs.php.md | Job chain |
| JobMiddleware.php.md | Custom middleware |
| JobTest.php.md | Job test |
Quick Reference
Attribute-based Job (L13 MAIN)
use Illuminate\Queue\Attributes\{Connection, Queue, Tries, Timeout, Backoff, MaxExceptions, FailOnTimeout, UniqueFor};
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
#[Connection('redis')]
#[Queue('podcasts')]
#[Tries(5)]
#[Timeout(120)]
#[Backoff([10, 30, 60])]
#[MaxExceptions(3)]
#[FailOnTimeout]
#[UniqueFor(3600)]
final class ProcessPodcast implements ShouldQueue
{
use Queueable;
public function __construct(public readonly Podcast $podcast) {}
public function handle(PodcastService $service): void { $service->process($this->podcast); }
public function failed(\Throwable $e): void { Log::error('Podcast failed', ['id' => $this->podcast->id, 'e' => $e]); }
}
Queue Routing (centralised)
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Queue;
public function boot(): void
{
Queue::route('podcasts', connection: 'redis', queue: 'media');
Queue::route('mail', connection: 'redis', queue: 'transactional');
}
→ Legacy public int $tries = 5 style — see legacy-properties.md
Best Practices
DO
- Use Attributes on Jobs, Listeners, Notifications, Mailables, Broadcast Events
- Centralise routing via
Queue::route()inAppServiceProvider::boot() - Use
#[AfterCommit]when dispatching inside a transaction finaljob classes, implementfailed(), monitor Redis with Horizon
DON'T
- Mix
#[Tries]andpublic int $tries(single source of truth) - Dispatch in a transaction without
#[AfterCommit] - Store large objects/closures in job constructor properties
- Use
syncdriver in production
What ships with it: 16 files
52.8 KB alongside SKILL.md
references/
- batching.md2.1 KB
- chaining.md2.4 KB
- dispatching.md2.0 KB
- failed-jobs.md1.8 KB
- horizon.md2.0 KB
- jobs.md2.7 KB
- legacy-properties.md4.0 KB
- middleware.md1.8 KB
- templates/BatchJob.php.md5.1 KB
- templates/ChainedJobs.php.md6.0 KB
- templates/JobMiddleware.php.md6.1 KB
- templates/JobTest.php.md7.5 KB
- templates/QueueableJob.php.md3.6 KB
- testing.md2.0 KB
- troubleshooting.md2.0 KB
- workers.md1.9 KB