Skip to content
AgileLogics
4 min read

Working with Queues & Background Jobs

Prerequisites: Modern PHP versions: 8.0 through 8.4

Since PHP is request-scoped (from the PHP lifecycle lesson), slow work (sending an email, processing an image) shouldn't run inline and make a visitor wait — a queue hands that work to a separate background worker process instead.

// Enqueue (Laravel example)
ProcessOrderExport::dispatch($order);

// A separate, long-running process consumes the queue:
// php artisan queue:work

Behind the queue itself is usually Redis or a database table — the web request just pushes a small message ("process order #42") and returns immediately, while a worker process (started separately, running continuously) picks it up and does the real work.