Lesson 20 / 25
Laravel and Symfony at a Glance
Compare the two major PHP frameworks and know when to use plain PHP.
Batteries included
Two frameworks dominate professional PHP. Laravel focuses on developer productivity: expressive routing, the Eloquent active-record ORM, Blade templates, migrations, queues, events, scheduled tasks, mail, authentication starters, the Artisan CLI and a large ecosystem (Livewire, Inertia, Horizon, Forge, Vapor). It is very popular for startups and product teams, including in India. Symfony is a set of decoupled, reusable components (HttpFoundation, Console, Routing, DependencyInjection, Messenger, Validator, Serializer) plus a full-stack framework with Doctrine ORM and Twig; it emphasises explicit configuration and long-term support releases, and many other projects, including Laravel and Drupal, use Symfony components. Both provide dependency injection containers, request and response objects, validation, CSRF protection and testing tools. Smaller options include Slim and Mezzio for microservices and APIs. Plain PHP is fine for small scripts and for learning, but for real web applications a framework's security defaults and conventions save time and prevent mistakes.
The same endpoint in Laravel and Symfony
Both return JSON for GET /orders/{id}.
<?php
// Laravel: routes/api.php
use App\Models\Order;
use Illuminate\Support\Facades\Route;
Route::get('/orders/{order}', function (Order $order) { // route model binding
return response()->json([
'id' => $order->id,
'status' => $order->status,
'total' => $order->total,
]);
});
// Symfony: src/Controller/OrderController.php
namespace App\Controller;
use App\Repository\OrderRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
final class OrderController extends AbstractController
{
#[Route('/orders/{id}', methods: ['GET'])]
public function show(string $id, OrderRepository $orders): JsonResponse
{
$order = $orders->find($id) ?? throw $this->createNotFoundException();
return $this->json(['id' => $order->getId(), 'status' => $order->getStatus()->value]);
}
}A fully equipped kitchen versus a modular one
Laravel is a fully fitted kitchen where everything has a standard place and you start cooking immediately. Symfony is a modular kitchen system: you choose the units and arrangement, and the parts are good enough that other kitchens borrow them.
Quick check: Which ORM is Laravel's default?
- Doctrine
- Hibernate
- Propel
- Eloquent
Answer
Eloquent — Laravel ships with Eloquent, an active-record ORM; Symfony commonly uses Doctrine.