← Back to the catalog

Skill · Version 1.0.0

Laravel queues and events

Runs background work with explicit retries, durable outcomes and clean transaction and tenant boundaries.

laravel-queues-events

See how it helps

When is it useful?

Use when exports, notifications or integrations should execute outside the request lifecycle.

What does it help you do?

  • Makes jobs safe against duplicate dispatch and sets bounded timeout and retry behavior.
  • Dispatches dependent work after commit and handles missing or changed records.
  • Prevents long-lived workers from carrying tenant or authentication state into another job.

Try asking this

Build an export job that survives duplicate delivery and worker restart while preserving each tenant's scope and failure status. Run exports for two tenants sequentially in the same worker and redeliver one job. Produce one scoped artifact per job without leaking earlier tenant context.

Detailed documentation

Read the skill’s original instructions, examples and checks in their authored language.

Details…Show less

Queues, Events & Scheduler

Queued jobs, retries and idempotency

  • Offload slow or external work (emails, webhooks, third-party APIs, exports, media processing) to ShouldQueue jobs. Never treat a queued job or event listener as guaranteed to run exactly once.
  • Make every job idempotent: guard side effects with state checks, unique database constraints, idempotency keys or ShouldBeUnique, so retries or duplicate dispatches never double-charge, double-send or corrupt records.
  • Set explicit $tries, $backoff (array of seconds), $timeout and $maxExceptions, and implement failed(\Throwable $e) to record permanent failure and clean up partial state.
  • Ensure the queue connection's retry_after in config/queue.php is strictly greater than the job's $timeout; otherwise a worker can pick up a second copy while the first is still running.

Payloads, transactions and worker state

  • Pass Eloquent models (via SerializesModels, which stores only the model identifier and re-queries on execution) or scalar IDs — never serialize large collections, request objects or binary blobs into the queue payload. Handle deleted or stale models cleanly when the job runs.
  • When dispatching a job or event inside a database transaction (or from a model observer), implement ShouldDispatchAfterCommit or call ->afterCommit() so workers never read uncommitted rows.
  • In long-lived queue workers (queue:work, Horizon, Octane), never leak static state, singleton properties, auth state or tenant context from one job or request into the next. Explicitly pass and restore tenant context per job, and note when a deploy requires php artisan queue:restart.

Events, notifications and scheduler

  • Use Events and Listeners to decouple domain side effects from the primary action, and Notifications (ShouldQueue) for user-facing messages across mail, database or Slack channels.
  • Keep scheduled closures/commands in routes/console.php (or app/Console/Kernel.php in Laravel 10) thin by delegating to services or jobs. Add ->withoutOverlapping() on tasks that could run past their interval and ->onOneServer() in multi-server deployments.

Included files 2

  • LICENSE.txt
  • SKILL.md

About this skill package

laravel-queues-events

laravel-queues-events: Build and maintain Laravel applications with consistent Eloquent models, queues, authorization and tested upgrades.

Details…Show less

laravel-queues-events

laravel-queues-events: Build and maintain Laravel applications with consistent Eloquent models, queues, authorization and tested upgrades.

Includes the complete skill and its supporting files (2 files). The exact authored scope is preserved below.

Original skill description (source language)

Use when building, debugging or reviewing Laravel queued jobs, workers, Horizon, job retries, timeouts, idempotency, afterCommit dispatch, events, listeners, notifications or scheduled tasks in a Laravel application.

Install the skill, review its source and trust settings, then enable it for the relevant project or agent.

Requirements

  • Orqestria installed on your computer.