What Is New in Symfony 6.4
Symfony 6.4 brings a host of refinements and new capabilities to the framework, focusing on developer experience and modern PHP practices. This release introduces several new features, marks the deprecation of some older patterns, and includes numerous improvements and bug fixes to keep your applications running smoothly.
| Category | Key Highlights |
|---|---|
| New Features | PDO Session Handler, HtmlSanitizer Component, Notifier push channels, improved Messenger, Clock component integration, new HttpClient retry strategies. |
| Improvements | Better UX for translations, profiler updates for Mailer and Cache, Symfony CLI Docker support, Serializer performance, new Form theme fragments. |
| Deprecations | Legacy session handlers, some Container and Config methods, old uglifyjs filter, certain DoctrineBridge and Form features. |
| Bug Fixes | Various fixes across the Form, Mailer, Messenger, Routing, Security, and Serializer components. |
What new components and tools were added?
Symfony 6.4 ships with two brand-new components. The HtmlSanitizer component provides a secure way to clean and sanitize HTML input, which is a common requirement for user-generated content. The Clock component becomes a first-class citizen, offering a time abstraction that makes testing time-dependent code much simpler.
For session management, a new PdoSessionHandler is introduced, offering a robust, database-backed session storage solution out of the box. The Notifier component expands its reach with support for push channels, enabling native mobile and web push notifications.
How does Symfony 6.4 improve the developer workflow?
Several enhancements directly impact day-to-day development. The translation commands get a UX overhaul, making it easier to manage missing translations. The Symfony Profiler receives updates for the Mailer and Cache panels, giving you deeper insights into email sending and cache operations.
The Symfony CLI now includes improved support for Docker, streamlining local project setup. For frontend integration, new Twig theme fragments for Form rendering offer more flexibility and control over your form layouts.
What has been upgraded in the HttpClient and Messenger?
The HttpClient component gains powerful new retry strategies, allowing you to define custom logic for retrying failed HTTP requests based on status codes, headers, or response content. This is invaluable for building resilient integrations with external APIs.
Messenger sees practical additions like the ability to list and describe available messages and handlers via a new command. It also improves the handling of stamps when messages are retried, giving you more control over the flow of your async operations.
What deprecated features should developers be aware of?
This release continues the framework's evolution by deprecating older patterns. Legacy session handlers are marked for removal, steering developers towards the newer, more efficient handlers. Several methods in the DependencyInjection and Config components are also deprecated in favor of more explicit alternatives.
In the Form component, the format option for Date/Time types is deprecated, encouraging the use of html5 format or custom widgets. The old uglifyjs filter in AssetMapper is deprecated, with Terser being the recommended replacement for JavaScript minification.
FAQ
Is the new HtmlSanitizer component ready for production use?
Yes, the HtmlSanitizer component introduced in 6.4 is stable and production-ready. It provides a secure, extensible way to sanitize HTML from untrusted sources, which is a common security need in web applications.
How do the HttpClient retry strategies work?
You can now implement the RetryStrategyInterface to create custom retry logic. The component can retry a request based not just on HTTP codes, but also by inspecting the response's headers or body, giving you fine-grained control over transient failures.
What is the main benefit of the Clock component integration?
Using the Clock component (now a core part of Symfony) makes your code more testable. By injecting a clock instance, you can easily mock time in your unit tests, eliminating flaky tests that depend on the system's actual time.
What should I use instead of the deprecated legacy session handlers?
You should migrate to the newer session handlers like NativeFileSessionHandler, PdoSessionHandler, or RedisSessionHandler. These are more efficient and better supported in the long term.
Are there any changes to the way translations are managed?
The main change is in the developer experience. Commands like debug:translation and translation:extract have improved output formats, making it clearer to identify missing or unused translations in your project.