Latest in branch 7.2
7.2.9
Released 31 Jul 2025
(10 months ago)
SoftwareSymfony
Version7.2
Status
End of life
Supported
PHP versions
PHP ≥ 8.2.0
Initial release7.2.0
29 Nov 2024
(1 year ago)
Latest release7.2.9
31 Jul 2025
(10 months ago)
End of bug fixesJul 2025
(Ended 10 months ago)
End of security fixesJul 2025
(Ended 10 months ago)
Release noteshttps://github.com/symfony/symfony/releases/tag/v7.2.9
Source codehttps://github.com/symfony/symfony/tree/v7.2.9
Documentationhttps://symfony.com/doc/current/index.html
Downloadhttps://symfony.com/download
Symfony 7.2 ReleasesView full list

What Is New in Symfony 7.2

Symfony 7.2 brings a focused set of enhancements and new features, primarily improving developer experience for HTTP interactions, console commands, and service configuration. The release continues the framework's modernization efforts with useful attributes and quality-of-life improvements.

Category Key Changes
New Features Query parameter mapping attribute, console command completion for arguments, lazy-aware event dispatcher interface.
Improvements Enhanced HttpClient payload methods, new `Number` constraint, `Uid` factory methods, `AssetMapper` path validation.
Deprecations Legacy event dispatcher methods, some `HttpClient` response methods, old `Uid` factory signatures.

How does Symfony 7.2 improve mapping HTTP query parameters?

The new #[MapQueryParameter] attribute is a game-changer for controller methods. It lets you automatically map individual query string parameters to typed arguments, eliminating the need to manually fetch from the request bag.

You can define optional defaults, apply PHP type casting, and even handle arrays with a specific format. This makes controller signatures more explicit and your code cleaner by leveraging Symfony's argument resolvers.

public function index(
    #[MapQueryParameter]
    string $q = '',
    #[MapQueryParameter]
    int $page = 1,
    #[MapQueryParameter('filters', filter: FILTER_VALIDATE_BOOL)]
    array $filters = []
) {}

What console command enhancements were added?

Symfony 7.2 introduces autocompletion for command arguments, not just options. When you define a #[AsCommand] attribute, you can now implement the CompleteInterface to provide suggested values for any argument, improving the CLI experience.

The CommandTester class also gets a new assertCommandIsSuccessful() helper. This provides a more readable and intuitive way to write tests for your console commands compared to checking the status code manually.

// In your command's configure() method
$this->addArgument('branch', InputArgument::REQUIRED);

// Then implement CompleteInterface
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
{
    if ($input->mustSuggestArgumentValuesFor('branch')) {
        $suggestions->suggestValues(['main', 'next', 'wip']);
    }
}

Are there new interfaces for modern PHP practices?

Yes, a new LazyEventDispatcherInterface has been added. This interface extends the core event dispatcher and is designed for use with lazy event listeners. It signals that the dispatcher can handle the proxying logic required for lazy-loaded services.

In practice, this is an internal improvement that solidifies the contract for dependency injection containers when dealing with event listeners marked as lazy. It ensures better integration and clarity within the service layer.

What HttpClient improvements should I know about?

The HttpClient component received practical additions. The toArray() and toArray() methods now accept a throw parameter. This gives you finer control over error handling when decoding JSON responses, allowing you to choose between getting a null value or throwing an exception on bad data.

Additionally, the TraceableHttpClient now provides the total number of requests made during a trace via a getTracedRequestsCount() method, which is useful for profiling and debugging.

$response = $client->request('GET', '...');
// Decode JSON, but don't throw on invalid JSON
$data = $response->toArray(throw: false);

What new constraints and utilities are available?

A new Number constraint has been introduced to validate that a value is a numerically valid string. It's more flexible than Type constraint for strings that represent numbers and complements the existing Range constraint.

The Uid component gets static factory methods like Uid::fromString(), Uuid::fromString(), and Ulid::fromString(). These provide a more object-oriented and unified way to instantiate UID objects compared to using constructors directly.

use Symfony\Component\Validator\Constraints\Number;
// Validates strings like "12.5", "-100", "1.2e3"
#[Number]
private string $numericString;

FAQ

Is the #[MapQueryParameter] attribute a replacement for #[MapQueryString]?
No, they serve different purposes. Use #[MapQueryString] to map the entire query string to a single DTO object. Use #[MapQueryParameter] to map individual query parameters directly to multiple controller arguments. Choose based on whether you need a structured object or simple, discrete parameters.

Do I need to change my event dispatcher services to implement the new interface?
No, this is not a breaking change. The existing event dispatcher implementation already supports lazy listeners. The new interface formalizes this capability. Your services will continue to work, and the framework will use the interface internally for better type hints.

Why deprecate the HttpClient response's toArray() method without arguments?
The parameterless toArray() method is not deprecated. The deprecation is for the $throw argument in certain internal context methods. The public method you use in your apps remains and is enhanced with the new throw parameter for better error handling.

How do I update my Uid component code to use the new factories?
Instead of new Ulid($string), you can now write Ulid::fromString($string). The new static methods offer a more consistent and readable API. The constructors remain for now, but using the factories is recommended for future compatibility.

What happens if I use a deprecated method from the event dispatcher?
Methods like EventDispatcherInterface::addListener() with a priority integer are deprecated in favor of using the priority parameter name. You'll see deprecation notices in the dev environment. Update your calls to use the named parameter to avoid issues in Symfony 8.

Releases In Branch 7.2

VersionRelease date
7.2.931 Jul 2025
(10 months ago)
7.2.828 Jun 2025
(11 months ago)
7.2.729 May 2025
(1 year ago)
7.2.602 May 2025
(1 year ago)
7.2.528 Mar 2025
(1 year ago)
7.2.426 Feb 2025
(1 year ago)
7.2.329 Jan 2025
(1 year ago)
7.2.231 Dec 2024
(1 year ago)
7.2.111 Dec 2024
(1 year ago)
7.2.029 Nov 2024
(1 year ago)
7.2.0-RC113 Nov 2024
(1 year ago)
7.2.0-BETA206 Nov 2024
(1 year ago)
7.2.0-BETA127 Oct 2024
(1 year ago)