Laravel
Laravel is the dominant PHP framework — a batteries-included stack in the Rails tradition, with expressive syntax, the Eloquent ORM, and an unusually complete first-party ecosystem covering auth, billing, queues, websockets, and deployment.
PHP still runs a huge share of the web, and Laravel is the reason modern PHP development feels current rather than legacy: typed code, dependency injection, first-class testing, and one-command scaffolding, deployable on nearly any host on earth.
TL;DR
- Laravel is convention-driven MVC: routes → controllers → Eloquent models → Blade views (or JSON).
- Eloquent is an Active Record ORM:
$post->commentswalks relations;Post::where(...)chains queries. - Artisan is the CLI for everything:
php artisan make:model Post -mcrgenerates model + migration + controller. - Middleware, validation, queues, events, and scheduling are built in — little third-party assembly required.
- The first-party ecosystem is the differentiator: Breeze/Jetstream (auth), Sanctum (API tokens), Horizon (queues), Forge/Vapor (deployment).
- Blade + Livewire (or Inertia + React/Vue) covers frontends without a separate SPA codebase.
Quick Example
Routes, a controller, and an Eloquent model:
Core Concepts
Artisan and Generators
Artisan is Laravel's command-line interface — scaffolding, migrations, queues, and a REPL:
Eloquent ORM
Active Record with expressive relations:
with() is the N+1 defense — the same query optimization concern as every ORM.
Routing and Middleware
Middleware wraps requests exactly like Express middleware — auth, rate limiting (throttle), CORS, and your own cross-cutting logic. apiResource generates the standard REST routes.
Validation
Validation is declarative and returns structured errors automatically:
For reuse, extract Form Request classes (php artisan make:request StoreUserRequest).
Migrations and Seeding
Fluent schema definitions, versioned in git, with factories and seeders for test data — standard migration discipline.
The Laravel Ecosystem
The first-party packages are a major reason teams pick Laravel:
Frontend-wise, the two mainstream paths are Livewire (stay in PHP, sprinkle reactivity) and Inertia (write React/Vue components, skip building a REST layer for your own UI).
Best Practices
Guard Mass Assignment
Queue Anything Slow
Email, PDF generation, API calls to third parties — dispatch them:
Laravel's queue system (database, Redis, SQS drivers) plus Horizon monitoring makes background jobs nearly free to adopt.
Cache Expensive Reads
See Caching for invalidation strategies.
Test with the Built-In HTTP Harness
Factories + an SQLite/RefreshDatabase test database give fast, real-database tests out of the box.
Laravel vs Alternatives
Within PHP, Laravel vs Symfony is convention vs configuration: Laravel optimizes for product velocity, Symfony for architectural explicitness in large enterprises.
Common Mistakes
Logic in Blade Templates
Templates should display data, not compute it. Push logic into controllers, models, or view composers — the same separation every MVC framework wants.
N+1 Queries in Loops
Enable Model::preventLazyLoading() in development to turn silent N+1s into exceptions.
Skipping the Queue Worker in Production
Dispatching jobs does nothing if no worker is running. Run php artisan queue:work under a supervisor (or use Horizon) and monitor failed jobs.
FAQ
Is PHP still worth using?
Modern PHP (8.x) is fast, typed, and actively developed — and it runs a vast share of the web. Laravel is the strongest argument: the developer experience rivals any ecosystem, and hosting is cheap and ubiquitous.
Laravel or Symfony?
Laravel for product velocity, convention, and ecosystem; Symfony for component-level control and long-lived enterprise systems. Laravel itself is built on many Symfony components, so the skills overlap.
Can Laravel serve as a pure API backend?
Yes — skip Blade, use Sanctum for token auth and API Resources for JSON shaping, and you have a conventional REST API backend for mobile or SPA clients.
How does Laravel handle realtime features?
Event broadcasting over WebSockets via Reverb (first-party server) or Pusher, with Echo on the client. Livewire also polls/streams for lighter cases.
What's the deployment story?
Anything from shared hosting to serverless: Forge provisions and manages VPSes, Vapor runs Laravel on AWS Lambda, and standard Docker images work everywhere in between.
Related Topics
- PHP — The language underneath
- Ruby on Rails — The convention-over-configuration original
- Django — The Python counterpart
- REST API Design — Resource conventions
- Message Queues — What Laravel queues abstract
- Authentication — Sessions, tokens, and Sanctum's model
- Caching — Strategies behind
Cache::remember
References
- Laravel Official Documentation
- Laracasts — The de facto Laravel video school
- Laravel News
- Pest Testing Framework