Modern Symfony tour

Symfony 6 LTS notes

Symfony 6 is a long-term-support line that needs PHP 8.1 or newer. It made attributes the default way to configure routes, validation, and services, and it kept backward compatibility inside the major version, so minor updates stay boring on purpose.

$ php bin/console --version

Symfony 6.4, LTS line, PHP 8.1 or newer required

What 7 changed

Symfony 7 needs PHP 8.2 or newer and removes the deprecations collected during version 6. Attributes stay the standard, services lean on constructor promotion and readonly properties, and upgrades hurt less when the previous version reports no deprecation warnings.

The practical rule is simple: keep the current version warning-free first, then move to the next major. A green deprecation log turns a major upgrade from a rewrite into a routine update.

Attributes everywhere

One attribute above a method now carries the route, the HTTP methods, and the access rule. The block below guards a page with a route plus a role check, with no extra configuration files involved.

use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; class HelloController { #[Route("/hello", methods: ["GET"])] #[IsGranted("ROLE_USER")] public function hello(): Response { return new Response("Hello"); } }

Symfony Runtime note

The Runtime component boots the front controller and reads the APP_ENV settings for you. Install it once and the public index file stays a few lines long, with environment handling in one tested place.

$ composer require symfony/runtime

Front controller now boots through Symfony Runtime

Next: Hero roadmap: the whole course on one page

Article author: Arthur Isaev