What Is New in Symfony 4.3?
Symfony 4.3 delivers a significant set of new features, improvements, and foundational updates that streamline development and enhance application capabilities. This release introduces several new components, refines existing ones, and prepares the ground for future Symfony 5.0.
| Category | Key Highlights |
|---|---|
| New Components & Features | Mailer, Messenger, Notifier, Mime, HttpClient, Expression Language for Security |
| Major Improvements | Form, Validator, Workflow, Cache, Console, Ldap |
| Deprecations | SwiftmailerBundle, WebServerBundle, some Container parameters, legacy code paths |
| Bug Fixes | Across multiple components including Form, Security, and Serializer |
What new components should I start using?
Symfony 4.3 brings several standalone, reusable components that solve common problems. The new Mailer and Mime components offer a modern alternative to Swiftmailer, built for better integration and testability. The Messenger component provides a solid message bus for handling queues, commands, and events right out of the box.
For HTTP interactions, the HttpClient component is a game-changer. It's a fast, asynchronous client that works consistently across all PHP environments. The Notifier component centralizes sending notifications via Slack, SMS, and other channels, making user alerts much simpler to manage.
How are existing components improved?
The Form component got a major overhaul with a new "inherit_data" option that simplifies complex nested forms. In practice, this removes a lot of boilerplate code when you need to share data between parent and child forms. The Validator now supports PHP 7.4 typed properties, allowing you to define constraints directly in your class declarations.
Workflow and Cache
The Workflow component now supports multiple state stores, letting you manage the state of an entity across different workflows. Cache improvements include PSR-6 and PSR-16 adapters for Doctrine\Common\Cache, easing migration from older caching libraries.
What is deprecated and needs attention?
This release marks the deprecation of several bundles and features to prepare for Symfony 5. The SwiftmailerBundle is deprecated in favor of the new Mailer component. The WebServerBundle is also deprecated, as the Symfony CLI or the PHP built-in server are better alternatives for local development.
Some container parameters related to the session and fragments are deprecated. You'll also find deprecations in the Security component's authorization checker and in some Form type options. Checking your deprecation logs after upgrading is crucial.
How does security get more expressive?
Symfony 4.3 integrates the Expression Language directly into the Security component. This allows for far more dynamic and complex access control rules directly in your security configuration. You can now write conditions that reference methods, properties, and services without creating custom voters for every single case.
access_control:
- path: ^/admin
allow_if: "is_granted('ROLE_ADMIN') and request.headers.get('X-Secure-Access') == '1'"
FAQ
Is the new HttpClient a replacement for Guzzle?
Yes, the Symfony HttpClient is a competitive alternative. It's designed to be fast, provides both synchronous and asynchronous interfaces, and has no external dependencies. It's a great choice for new projects or if you want to reduce third-party packages.
Should I migrate from Swiftmailer to the new Mailer immediately?
Not necessarily. The SwiftmailerBundle will continue to work in 4.3 and 4.4. However, for new features and long-term support, plan to migrate. The new Mailer component has a simpler API and better integration with Messenger for queuing emails.
What's the main benefit of the Messenger component?
It standardizes how you dispatch and handle messages, commands, and events. Its biggest win is the simple configuration for routing messages to transports (like Doctrine, Redis, AMQP) for async processing, which was more fragmented before.
Are the PHP version requirements changing in 4.3?
No, Symfony 4.3 still supports PHP 7.1.3 and above. However, some new features, like typed property validation, require PHP 7.4 to use. The core framework remains compatible with the stated PHP range.
How disruptive is the upgrade from Symfony 4.2 to 4.3?
For most applications, it's a smooth upgrade. The main work involves addressing deprecation warnings logged in the dev environment. The changes are additive, so you can adopt new components like HttpClient at your own pace without breaking existing functionality.