Popular PHP Frameworks
What Laravel and Symfony add on top of raw PHP, and when each is the right choice.
3 min read
Everything covered so far in this course is plain PHP — no framework required. In practice, almost every serious PHP application is built on top of one, because a framework solves the same handful of problems (routing, database access, security, request handling) that every non-trivial app needs, consistently and safely.
Why reach for a framework at all
<?php
// Handling routing by hand quickly becomes unmanageable:
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if ($path === '/users' && $_SERVER['REQUEST_METHOD'] === 'GET') {
// list users
} elseif (preg_match('#^/users/(\d+)$#', $path, $matches)) {
// show user $matches[1]
}
// ...this grows unmanageable fast, for every route in a real application.A framework provides a proper router, a consistent way to talk to a database, built-in protection against common vulnerabilities (covered in the next lesson), and a structure the whole team can follow — replacing dozens of these hand-rolled, error-prone patterns with a single well-tested foundation.
Laravel: the most popular modern PHP framework
<?php
// routes/web.php
Route::get('/users/{id}', [UserController::class, 'show']);
// app/Http/Controllers/UserController.php
class UserController extends Controller {
public function show(int $id) {
$user = User::findOrFail($id);
return view('users.show', ['user' => $user]);
}
}Laravel emphasizes developer experience and rapid setup — expressive routing, an ORM called Eloquent (User::findOrFail($id) above is a full database query, no SQL written), built-in authentication scaffolding, and a large ecosystem of official packages for jobs like queues, caching, and file storage. It's the framework most new PHP projects reach for today, and the one this very course's own backend is built on.
Symfony: components-first, enterprise-friendly
<?php
// A Symfony controller
class UserController extends AbstractController {
#[Route('/users/{id}', methods: ['GET'])]
public function show(int $id, UserRepository $repository): Response {
$user = $repository->find($id);
return $this->render('users/show.html.twig', ['user' => $user]);
}
}Symfony takes a more modular approach — its individual pieces (routing, HTTP handling, dependency injection) are usable as standalone components even outside a full Symfony application, and in fact Laravel itself is built on top of several Symfony components under the hood. Symfony tends to be favored for larger, longer-lived enterprise applications where strict structure and configurability matter more than the fastest possible time-to-first-feature.
Choosing between them
Laravel's opinionated defaults and gentler learning curve make it the more common starting point, especially for teams that want to move fast without making every architectural decision themselves. Symfony rewards teams that want fine-grained control over each piece and are willing to invest more setup time up front. Both are mature, actively maintained, and capable of running large production systems — the choice is more about team preference and project constraints than one being objectively "better."
The rest of the PHP ecosystem
Beyond these two, WordPress (built on plain PHP, not a modern framework) still powers a huge share of the web's content-driven sites, and lighter frameworks like Slim exist for building small APIs without the overhead of a full-stack framework. Understanding plain PHP — everything covered earlier in this course — is what makes any of these frameworks make sense, since each one is, underneath, still just PHP.
Test what you just learned
4 quick questions. Get all of them right to unlock the next lesson.
You can take the quiz without an account — logging in just lets your result count toward your progress.