Kritim Yantra
Jul 08, 2025
You built your first Laravel app. π
It works! Users can register, reset passwords, maybe even get a confirmation email.
But then... it feels slow. π©
After submitting a form, it hangs for 2β3 seconds.
You stare at the loading spinner and think, βSomethingβs not right.β
Letβs be honest: nobody wants to wait for an email to send before the page reloads.
You donβt need a faster server.
You donβt need Redis or Horizon (yet).
β You just need Laravel Queues.
And the best part?
You can set it up in 10 minutes β even on shared hosting.
Letβs go! π
Imagine this: You walk into a restaurant. You order 3 biryanis. π
Now, should the cashier:
Laravel queues are that kitchen. π§βπ³
Instead of processing time-heavy tasks right now (like sending emails), Laravel queues them for later β so your app responds instantly, and heavy work happens in the background.
You donβt need to run a daemon or install Redis.
You just need:
Edit your .env
:
QUEUE_CONNECTION=database
Then run this:
php artisan queue:table
php artisan migrate
Now your jobs will go into a jobs
table.
php artisan make:job SendWelcomeEmail
Edit the handle()
method inside:
use Illuminate\Support\Facades\Mail;
public function handle()
{
Mail::to($this->user->email)->send(new WelcomeMail($this->user));
}
Anywhere in your app (like a controller):
SendWelcomeEmail::dispatch($user);
β Done! Itβs in the queue now β ready to be processed.
queue:work
in routes/console.php
In Laravel 11+:
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Facades\Log;
Schedule::command('queue:work --stop-when-empty')
->everyMinute()
->withoutOverlapping()
->before(function () {
Log::info('Queue started at ' . now());
})
->after(function () {
Log::info('Queue finished at ' . now());
});
Command:
cd /home/your-user/public_html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
Frequency: Every minute (or every 5, if needed)
Thatβs it β every minute, your app will check the queue and process jobs!
Before using queues:
After using queues:
π₯ Your app feels 10x faster.
And you didn't change servers or buy anything fancy.
β
Use php artisan schedule:list
to see upcoming tasks
β
Use Log::info()
to debug job runs
β
Use php artisan queue:failed
to see failed jobs
β
Retry with php artisan queue:retry all
And best of all: You did it without needing to install anything. π
Try adding a background email or image resize job to your app right now.
Let Laravel do the heavy lifting β and give your users a snappy, smooth experience theyβll love. π
What's the first task you'd like to push into the background using Laravel queues?
π Drop it in the comments β letβs build faster apps together!
Absolutely! Use QUEUE_CONNECTION=database
and you're good to go.
Yes β Laravel has retry features built-in. You can customize retry delay, attempt counts, etc.
β Yes! Many Laravel apps on shared hosting use this exact method. Just make sure you test your jobs before going live.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google