Skip to main content

Claude/ChatGPT Prompt to Set Up Laravel Queues with Horizon

Configure Redis queues with Horizon: supervisors, retries, backoff, timeouts, failure alerts, and a rate-limited job example.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt casts the model as a senior Laravel engineer and asks for working config files and a real job class rather than pseudocode. It defines five deliverables: a config/horizon.php with supervisors mapped to your queues, with sensible processes, balance strategy, and per-queue priorities for local and production, an example job implementing retryUntil or backoff with tries and timeout set deliberately, a RateLimited middleware on the job plus the limiter definition so a fragile downstream API is not hammered, failure handling using the failed_jobs table, the failed() hook, and an alert to your channel, and the supervisor command to keep Horizon running plus how to monitor throughput and wait times. The structure works because it sets retries, backoff, and failure alerts together, so the silent failures get surfaced.

Four variables drive it. [queues] names the queues — default, emails, exports — that supervisors map to. [driver] describes the infra, like Redis on a single worker host. [alert_channel] sets where failures notify, such as Slack #alerts. [job_purpose] describes what the example job does, like syncing contacts to a rate-limited CRM API, which shapes the RateLimited middleware. The advice to set timeout below your retryUntil window is the load-bearing part: get that wrong and jobs stack up faster than they clear, turning a transient hiccup into a growing backlog you don't notice until users do.

When to use it

  • You run Laravel queues with Horizon and want supervisors, retries, and alerts configured together.
  • A fragile downstream API needs rate limiting so jobs don't hammer it into failure.
  • Silent failures — a job retrying forever or a backlog building — are a real risk.
  • You want per-queue priorities and a balance strategy for both local and production.
  • Failure alerts to a channel like Slack matter so you hear about problems before users.
  • You need a real job class showing retryUntil or backoff, tries, and timeout set deliberately.

Example output

Expect each config and PHP file in its own fenced block headed by its path. A config/horizon.php maps supervisors to [queues] with sensible processes, a balance strategy, and per-queue priorities for local and production over [driver]; an example job implements retryUntil or backoff with tries and timeout reasoned about; a RateLimited middleware plus limiter definition protects the API behind [job_purpose]; failure handling uses the failed_jobs table, the failed() hook, and an alert to [alert_channel]; and the supervisor command keeps Horizon running with notes on monitoring throughput and wait times. It is buildable configuration, not pseudocode.

Pro tips

  • List your real [queues] so supervisors and per-queue priorities map to how your workload actually splits.
  • Describe [driver] accurately, since processes and balance strategy depend on your Redis and worker setup.
  • Set [job_purpose] to the real downstream so the RateLimited middleware matches that API's limits.
  • Point [alert_channel] at a channel you actually watch so failure notifications reach someone.
  • Set timeout below your retryUntil window, or jobs stack up faster than they clear.
  • Configure retries, backoff, and alerts together so silent failures surface before users feel them.

Frequently Asked Questions

How does this prevent hammering a fragile downstream API?
It adds a RateLimited middleware on the job plus a limiter definition, shaped around your `[job_purpose]`. This keeps the job from overwhelming a fragile downstream service like a rate-limited CRM API even when many jobs queue up at once.
Why set timeout below the retryUntil window?
If timeout is not below your retryUntil window, jobs stack up faster than they clear and a transient hiccup grows into a backlog. The prompt has you reason about tries and timeout deliberately to avoid that silent failure mode.
Where do failure alerts go?
Failure handling uses the failed_jobs table, the failed() hook, and an alert to your `[alert_channel]`, defaulting to Slack #alerts. Point it at a channel you actually watch so you hear about problems before users do.
Can I configure multiple queues with different priorities?
Yes. The `[queues]` variable lists your queues, defaulting to default, emails, and exports, and config/horizon.php maps supervisors to them with per-queue priorities and a balance strategy for both local and production.
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