Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 62 ยท Getting Started

What Is Symfony?

Learn what Symfony is, how the framework differs from its reusable components, how releases and LTS versions work, and how this tutorial runs its examples.

Symfony is two things at once. It is a set of more than fifty reusable PHP libraries, called components, and it is a full-stack web framework that glues the most useful of those components together. The same code that powers a Symfony application also powers many other projects: Laravel, Drupal, Magento and Composer itself all depend on Symfony components. When you learn Symfony, you learn a toolbox that shows up all over the PHP world.

This lesson explains the difference between the components and the framework, how Symfony versions are released, how Symfony compares with Laravel, what you will build in this tutorial, and how the examples work on this site. You should be comfortable with modern PHP first: classes, interfaces, namespaces and attributes are all used constantly. If they are new to you, start with the PHP tutorial and come back.

Components and the framework

A component is a standalone library that solves one problem. It has no hidden dependency on the rest of Symfony, so you can use it in any PHP project, with or without a framework. A few examples:

Component What it does
HttpFoundation Object-oriented Request and Response classes
Routing Maps URLs to controllers and generates URLs
HttpKernel The engine that turns a Request into a Response
DependencyInjection The service container
EventDispatcher Lets parts of your code react to events
Console Builds command-line tools
Validator, Form, Serializer Validate data, build forms, convert objects to JSON
Messenger Sends messages to handlers, sync or async

The Symfony framework is what you get when you install the symfony/framework-bundle package. It wires a selection of components together, adds a configuration system, a directory layout and a collection of conventions, so you can write a controller in minutes instead of assembling a kernel yourself. On top of the framework you add other packages: Twig for templates, Doctrine for databases, Security for logins.

flowchart TB
    App["Your application code<br/>(controllers, entities, templates)"]
    FW["FrameworkBundle<br/>(configuration + conventions)"]
    C1["HttpFoundation"]
    C2["Routing"]
    C3["HttpKernel"]
    C4["DependencyInjection"]
    C5["EventDispatcher"]
    App --> FW
    FW --> C1
    FW --> C2
    FW --> C3
    FW --> C4
    FW --> C5
    C3 --> C1
    C3 --> C5

Your code sits on the framework bundle, which assembles independent components. Each component can also be used alone.

Here is a taste of using a component without any framework. The next example is a plain-PHP stand-in written for this lesson: it mimics the idea of HttpFoundation's Request and Response classes, which wrap PHP's raw superglobals and echo calls in objects.

PHP A component used on its own (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

The point: Request and Response are useful by themselves. The framework only becomes necessary when you want routing, configuration, a container and a console as a ready-made package.

Framework or microframework?

Symfony is flexible about size. A fresh project from the skeleton template contains only the kernel, the console and a few config files. You add what you need with Composer. A webapp project starts with Twig, Doctrine, the Mailer and more. Both are the same framework underneath, which is why Symfony is used for tiny APIs and for enormous platforms.

Versions and long-term support

Symfony follows a predictable schedule, so you can plan upgrades:

  • A minor version (7.1, 7.2, 7.3, 7.4) arrives about every six months, in May and November.
  • A major version (7.0, 8.0) arrives every two years, in November. It contains no new features compared with the last minor of the previous line: it simply removes the deprecated code.
  • The last minor of each line (for the 7 line, version 7.4) is the LTS (long-term support) release. It gets bug fixes and security patches for years rather than months.
  • Minor versions keep backward compatibility: if your code runs without deprecation notices on 7.4, it should run on 8.0.

This tutorial targets Symfony 7.x, and nearly everything also applies to Symfony 8, which requires a newer PHP. The practical upgrade path is always the same: move to the newest 7.x, fix every deprecation, then bump to the next major. You can check the exact support dates and PHP requirements on the official release page, because they change faster than any tutorial.

flowchart LR
    A["7.0"] --> B["7.1"] --> C["7.2"] --> D["7.3"] --> E["7.4<br/>LTS"] --> F["8.0"]

Minor versions arrive twice a year; the last minor of a line is the LTS and leads into the next major version.

Symfony and Laravel at a glance

Many PHP developers meet both. They share a lot (Laravel uses Symfony components such as HttpFoundation and Console) but make different choices:

Topic Symfony Laravel
Style Explicit, configurable, decoupled Convention-first, "magic" helpers and facades
Services Constructor injection with autowiring Container plus facades and helpers
Database layer Doctrine ORM (data mapper: plain objects) Eloquent (active record: models save themselves)
Templates Twig Blade
Configuration YAML/PHP files plus attributes PHP config files
Extras Flex recipes, Messenger, components usable alone First-party ecosystem (Forge, Livewire, Cashier...)

Neither is "better". Symfony rewards you with a very clean architecture and long-term stability; Laravel optimizes for speed of getting started. If you have used Laravel, expect to write a little more configuration and a lot less magic.

What you will build

This tutorial walks through the same path a real project takes:

  1. Getting started: install, project layout, Flex, and the request lifecycle.
  2. Routing, controllers and Twig for pages.
  3. The service container, configuration, forms and validation.
  4. Doctrine, security, events, Messenger and the console.
  5. APIs, caching, testing and deployment, then four complete projects: a blog, a task manager, a JSON bookstore API and an async report generator.

How the examples work here

Symfony needs Composer packages, a web server and often a database, none of which can run inside a browser lesson. So every lesson is honest about two kinds of code:

  • Real Symfony code appears in plain, read-only code blocks. You copy it into a project on your own machine.
  • Runnable stand-ins are small plain-PHP programs (a mini kernel, a mini container, a mini router, a mini validator) that you can edit and run right here. They are not Symfony, but they behave like the real thing at the level that matters, so you learn the mechanism by watching it work. Each lesson tells you which parts are real and which are stand-ins.

Here is what a "real" snippet looks like. This one is read-only, and you will understand every line of it by the end of the Routing chapter:

PHP
// src/Controller/HelloController.php (real Symfony, read-only)
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

final class HelloController
{
    #[Route('/hello', name: 'app_hello')]
    public function __invoke(): Response
    {
        return new Response('Hello from Symfony!');
    }
}

And one more stand-in, to show how a framework pulls components together. It lists which components a tiny "framework" needs to answer one request:

PHP A framework as a list of components (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a Symfony component?

    Components such as HttpFoundation or Console are independent libraries. The framework is what assembles them.
  2. 2. Which release is the LTS version of a Symfony line such as the 7 series?

    The final minor of each major line is the long-term support release and is supported for years.
  3. 3. Which description matches Doctrine, the usual Symfony database layer?

    Doctrine is a data mapper: your entities are plain PHP objects and a separate entity manager persists them.
  4. 4. Why are the runnable examples in this tutorial called stand-ins?

    Stand-ins teach the mechanism. The real Symfony code is shown in read-only blocks.

Summary

  • Symfony is both a collection of reusable components and a full-stack framework that assembles them.
  • Components such as HttpFoundation and Console work without the framework, and other projects like Laravel and Drupal use them.
  • Minor versions arrive twice a year, the last minor of a line is the LTS, and upgrades are smooth if you fix deprecations first.
  • Compared with Laravel, Symfony favours explicit configuration and decoupled design; Doctrine is a data mapper, Twig is the template engine.
  • Real Symfony code is read-only here; runnable stand-ins teach the mechanisms.

Next up: Installing Symfony and the CLI.