Skip to main content

Laravel Queue Job and Event System Designer

Design a robust queue and event-driven architecture in Laravel — jobs, listeners, event sourcing, and failure handling with Horizon.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt designs a complete queue-based, event-driven system in Laravel for a feature that shouldn't block the request cycle. It produces the events, queued listeners, job classes with retry logic, failure handling, an event subscriber, Horizon configuration, an event-log migration, and a monitoring widget — plus tests using Queue::fake(). The goal is a pipeline that stays healthy under real load rather than a single fire-and-forget job.

The variables tune reliability and routing. [feature_description] names the workflow, [events_list] becomes the actual event classes, and the listeners are configured with [queue_driver] as the connection and [queue_name] as the queue so work lands on the right worker. [max_tries] and [backoff_strategy] control retry behavior, which is where most home-grown queues fail — too few tries drops work, no backoff hammers a failing dependency. [batch_operation] defines what gets processed in a batch. Because retries, backoff, and failure handling are designed up front with Horizon in mind, the output is built to survive transient failures.

When to use it

  • Moving slow work (emails, fulfilment, webhooks) out of the HTTP request cycle
  • Designing an event-driven flow where one action triggers several downstream listeners
  • Setting up jobs with sensible retry and backoff instead of naive immediate retries
  • Configuring Horizon to manage workers across named queues
  • Adding failed-job handling and notifications so silent failures don't pile up
  • Batch-processing bulk operations like sending many notification emails

Example output

You get a set of event classes from your [events_list], queued listener classes pinned to your [queue_driver] connection and [queue_name], job classes declaring [max_tries] and the [backoff_strategy], a failed-job handler with notifications, an event subscriber, a Horizon config block, a migration for an event-log table, and a monitoring widget. Tests use Queue::fake() to assert jobs are dispatched without actually running them. The result reads as a coherent pipeline rather than scattered dispatch calls.

Pro tips

  • Name [events_list] as past-tense domain facts (OrderPlaced, PaymentProcessed) so listeners read naturally and the flow is easy to trace
  • Match [queue_driver] to your infrastructure — redis is standard for Horizon; database queues won't give you Horizon's dashboard
  • Set [max_tries] and [backoff_strategy] to fit the failure mode: exponential backoff is right for flaky external APIs, not for permanent errors
  • Use a dedicated [queue_name] per workload so a flood of one job type can't starve another
  • Keep [batch_operation] genuinely batchable; wrapping unrelated work in a batch just complicates failure handling
  • Rely on Queue::fake() in tests to assert dispatch and arguments without spinning up real workers, then add a few integration runs for the happy path

Frequently Asked Questions

Does this require Laravel Horizon?
The prompt is designed around Horizon for managing and monitoring queue workers, and it generates a Horizon config block. Horizon needs the Redis queue driver, so if you use a different driver you will lose the dashboard and need to adapt the worker setup.
How does it handle jobs that keep failing?
Jobs are configured with a maximum number of tries and a backoff strategy, and the prompt adds failed-job handling with notifications. After the retries are exhausted, the job lands in the failed jobs table so you can inspect or replay it rather than losing the work silently.
What does Queue::fake() do in the generated tests?
Queue::fake() intercepts dispatched jobs so your tests can assert that the right job was queued with the right arguments without actually executing it. This keeps tests fast and deterministic while still verifying the event-to-job wiring.
Should I put every event on the same queue?
No. Using a dedicated queue name per workload prevents a surge of one job type from starving another. The prompt lets you name the queue precisely so high-volume work and time-sensitive work stay isolated.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Laravel & PHP Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support