Laravel for Beginners: Setting Up Your First Project
A complete first-day guide to Laravel — installation, folder structure, your first route, and your first migration.
Anything that talks to the outside world — sending an email, calling a third-party API, generating a report — shouldn't happen while a user is sitting there waiting for a page to load. Laravel's queue system exists exactly for this.
A request that sends a welcome email synchronously is only as fast as your SMTP provider's slowest day. Dispatch it to a queue instead, and the HTTP response returns immediately while a background worker handles the email whenever it gets to it.
php artisan make:job SendWelcomeEmail
class SendWelcomeEmail implements ShouldQueue
{
use Queueable;
public function __construct(public User $user) {}
public function handle(): void
{
Mail::to($this->user)->send(new WelcomeMail($this->user));
}
}
SendWelcomeEmail::dispatch($user);
That single dispatch() call serializes the job and pushes it onto whatever queue driver you've configured — database, Redis, or SQS.
Jobs sit in the queue until a worker process picks them up:
php artisan queue:work --tries=3
--tries=3 means a failing job (a timeout, a third-party API being down) retries up to three times before landing in the failed_jobs table for you to inspect.
Need to send a follow-up email exactly 24 hours later? Delay the dispatch instead of building your own scheduler:
SendFollowUpEmail::dispatch($user)->delay(now()->addDay());
Or chain several jobs that must run in strict order, where each only starts after the previous succeeds:
Bus::chain([
new ProcessPayment($order),
new GenerateInvoice($order),
new SendInvoiceEmail($order),
])->dispatch();
--timeout so one stuck job doesn't block the entire worker indefinitely.Queues are the single highest-leverage change you can make to a Laravel app's perceived speed — most of what feels "slow" in a web app is actually something that should never have been synchronous in the first place.
A complete first-day guide to Laravel — installation, folder structure, your first route, and your first migration.
API routes, resources, Form Request validation, correct status codes, and Sanctum auth — a real, production-reasonable Laravel API.
One-to-many, many-to-many, polymorphic, and the N+1 query trap that catches almost every Laravel developer at least once.