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

ComponentWhat it's responsible for
HttpKernelTurns a Request into a Response — the core request/response cycle
RoutingMaps URLs to the controller that should handle them
DependencyInjectionThe service container — wires your classes together automatically
Doctrine ORMMaps PHP objects (Entities) to database tables (not a Symfony component itself, but the default ORM choice)
TwigThe 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?

ReasonWhat it means for you
Enterprise-readyBuilt for large, long-lived applications with strict structure and testability
Reusable componentsSkills transfer directly to Laravel and other frameworks that reuse Symfony pieces
Powerful service containerManages object creation and wiring for you, once you learn the pattern
Long-term support releasesPredictable upgrade path backed by a large company (SensioLabs) and community
Next steps: Head to Installation & Setup to create your first Symfony project via Composer.