Queueing Jobs and Managing Queues
Some tasks — sending emails, generating reports, processing uploads — take too long to run inline during a web request. Laravel's queue system lets that work happen in the background instead.
Creating a Job
php artisan make:job ProcessPodcast
class ProcessPodcast implements ShouldQueue
{
use Queueable;
public function __construct(public Podcast $podcast) {}
public function handle(): void
{
// long-running processing here
}
}
Dispatching a Job
ProcessPodcast::dispatch($podcast);
Running the Queue Worker
php artisan queue:work
This command starts a long-running process that pulls jobs off the queue one at a time and executes them.
Queue Drivers
- database — simple, stores jobs in a table
- redis — fast, production-friendly
- sync — runs jobs immediately, useful for local testing
The database driver is fine to start with, but production applications almost always move to something faster and more reliable — most commonly Redis.
Ready to master Laravel Training Course?
Join Uncodemy's hands-on Laravel program and build real, production-ready applications.
