Symfony Tutorial
Symfony is a robust, enterprise-grade PHP framework built from a set of independent, reusable components. Those same components power large parts of the PHP ecosystem — Laravel, Drupal, and many other projects all rely on pieces of Symfony under the hood, which is why understanding it pays off even beyond Symfony apps themselves.
Where this fits: Symfony is a bigger, more structured framework than Slim, and takes a different approach from CakePHP's convention-heavy style — Symfony favors explicit configuration and a powerful dependency injection container. Composer knowledge from the Composer track is assumed here.
Symfony's Building Blocks
| Component | What it's responsible for |
|---|---|
HttpKernel | Turns a Request into a Response — the core request/response cycle |
Routing | Maps URLs to the controller that should handle them |
DependencyInjection | The service container — wires your classes together automatically |
Doctrine ORM | Maps PHP objects (Entities) to database tables (not a Symfony component itself, but the default ORM choice) |
Twig | The templating engine used to render HTML views |
A Quick Look Ahead
Example: A Minimal Controller
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class ArticleController extends AbstractController
{
#[Route('/articles/{id}', name: 'article_show')]
public function show(int $id)
{
return $this->render('article/show.html.twig', ['id' => $id]);
}
}
Note: This is correct, real Symfony code — but this website's own project doesn't have Symfony installed, so you won't see it actually run on this page. Follow along in your own project after the next page's installation steps.
Why Learn Symfony?
| Reason | What it means for you |
|---|---|
| Enterprise-ready | Built for large, long-lived applications with strict structure and testability |
| Reusable components | Skills transfer directly to Laravel and other frameworks that reuse Symfony pieces |
| Powerful service container | Manages object creation and wiring for you, once you learn the pattern |
| Long-term support releases | Predictable upgrade path backed by a large company (SensioLabs) and community |
Next steps: Head to Installation & Setup to create your first Symfony project via Composer.