Skillshub laravel-background-processing
Scalable asynchronous workflows using Queues, Jobs, and Events. Use when implementing queued jobs, event-driven workflows, or async processing in Laravel. (triggers: app/Jobs/**/*.php, app/Events/**/*.php, app/Listeners/**/*.php, ShouldQueue, dispatch, batch, chain, listener)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/laravel-background-processing" ~/.claude/skills/comeonoliver-skillshub-laravel-background-processing && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/laravel-background-processing/SKILL.mdsource content
Laravel Background Processing
Priority: P1 (HIGH)
Structure
app/ ├── Jobs/ # Asynchronous tasks ├── Events/ # Communication flags └── Listeners/ # Task reactions
Implementation Guidelines
Queued Jobs
- Job Creation: Use
. Classes must implementphp artisan make:job ProcessOrder
.ShouldQueue - Execution: Implement logic inside the
method. Pass only model IDs to the constructor, not the full Eloquent model.handle() - Dispatching: Trigger via
.ProcessOrder::dispatch($orderId)
Advanced Workflow Patterns
- Job Chaining: Use
for sequential dependencies. Handle failures withBus::chain([new ProcessPayment($order), new SendReceipt($order)])->dispatch()
.->catch(fn => ...) - Job Batching: Use
. UseBus::batch([new ImportRow(1), ...])->then(...)->catch(...)->dispatch()
to abort and track via$this->batch()->cancel()
.$batch->progress()
Events & Listeners
- Scaffolding: Run
andphp artisan make:event OrderPlaced
.php artisan make:listener SendConfirmation --event=OrderPlaced - Async Execution: Add
to listeners to process them asynchronously.ShouldQueue - Activation: Trigger with
.Event::dispatch(new OrderPlaced($order))
Reliability & Monitoring
- Error Handling: Implement
in your job class. Usepublic function failed(Throwable $exception)
andpublic int $tries = 3
for retries.public int $backoff = 60 - Setup: Run the
migration to track dead jobs.queue:failed-table - Monitoring: Use Laravel Horizon (run
) for real-time observability; never usephp artisan horizon
in production.queue:work
Anti-Patterns
- No heavy logic in request path: Defer tasks >100ms to Queues.
- No full model in job payload: Pass IDs; Eloquent fetches on run.
- No deep event listener chains: Keep listener depth shallow.
- No unmonitored queues: Configure retries and Horizon alerts.