Queue Commands in Laravel 11

laravel 11 queue listen command
11 August 2025


Hello dear friend! Today we want to talk about one of the powerful features of Laravel, namely queue commands. This feature allows you to perform heavy tasks asynchronously. It is possible that some tasks in applications may be time-consuming and heavy, such as sending emails, processing images, or heavy operations on databases. Using the queue can help you let the user continue working seamlessly and you can manage these tasks in the background.


In Laravel, by using the queue commands, we can easily add tasks to the queue and then process them in an asynchronous manner. In version 11 of Laravel, several improvements and new features have been added that have made working with queues easier. We can easily add tasks to the queue and use the command queue:listen to listen for queue tasks.


Now let's look at a practical example together. Suppose we have a task for sending an email. We start by creating a job class and setting the email parameters in that class. Then, we will add the job to the queue. By using the command queue:listen, we can listen to the queue for processing tasks in order. This method is efficient and effective!


Now let's look at some code examples that show how we can perform this task. If you are also interested in performance optimization and reducing response time, using queues in Laravel is highly recommended.


// Creating a new job
php artisan make:job SendEmailJob

// Job class
namespace App\Jobs;

use Mail;
use App\Mail\SendEmail;
use Illuminate\Bus\Dispatcher;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendEmailJob implements ShouldQueue
{
use Dispatchable;

protected $emailData;

public function __construct($emailData)
{
$this->emailData = $emailData;
}

public function handle()
{
Mail::to($this->emailData['to'])->send(new SendEmail($this->emailData));
}
}

// Adding the job to the queue
SendEmailJob::dispatch($emailData);

Now let's look at the following code line by line:


Line 1: Creating a new job


php artisan make:job SendEmailJob With this command, we create a new class for the email sending job.


Job Class


In this section, we define a class for the job that must implement ShouldQueue to specify that this job is executed through the queue.


Constructor


In the constructor (__construct), this class receives email data as parameters.


Handle Method (handle)


In this method, we use the Mail class to send the email and send the email-related data.


Adding the Job to the Queue


By using SendEmailJob::dispatch($emailData), we add our job to the queue to be processed at the appropriate time.


FAQ

?

How can I create a new job in Laravel?

?

How can I add jobs to the queue?

?

How can I add long-running operations to Laravel's queue?

?

How can I process queue jobs?

?

Can I monitor the status of queued jobs in Laravel?