What Is New in Symfony 3.4
Symfony 3.4 introduces a set of refinements and new components, focusing on developer experience and modernizing the codebase. This release paves the way for Symfony 4 while maintaining full backward compatibility for existing applications.
| Category | Key Changes |
|---|---|
| New Features | New Messenger & Serializer components, improved Dotenv, new "symfony/contracts" package. |
| Improvements | Simplified service configuration with "defaults", autowiring by type, and a reworked directory structure. |
| Deprecations | Several features are soft-deprecated to prepare for Symfony 4.0, including some container parameters and class names. |
| Bug Fixes | Numerous fixes across the framework, especially in Form, Console, and HttpKernel components. |
| Security | Enhancements to the security component, including improvements to the voter system and security checks. |
How Did Symfony 3.4 Improve Service Configuration?
The service configuration system received major usability upgrades. The most significant change is the introduction of the defaults key and autowiring by type within service definitions.
This allows you to set common configuration (like autowiring, tags) for all services in a file at once. In practice, it drastically reduces the verbosity of your services.yml file, making it cleaner and easier to manage.
Example Configuration
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
What New Components Were Added in Symfony 3.4?
Symfony 3.4 debuted two important new components: Messenger and Serializer. These were previously part of third-party bundles but are now officially integrated into the core framework.
The symfony/messenger component provides a message bus system for handling tasks asynchronously or synchronously. The symfony/serializer component offers a powerful object serializer and deserializer for formats like JSON and XML.
Additionally, the new symfony/contracts package was introduced. This contains a set of abstract interfaces that define standard behavior, promoting interoperability between Symfony components and third-party libraries.
What Are the Key Deprecations to Watch For?
This release includes strategic deprecations to guide developers towards Symfony 4.0 patterns. Common targets include old directory structures and certain container parameters.
For instance, using the %kernel.root_dir% parameter is now deprecated in favor of %kernel.project_dir%. The old app/Resources directory structure is also deprecated, with templates now recommended to live in templates/.
These changes are non-breaking in 3.4 but will trigger deprecation notices. Addressing them early makes the eventual upgrade to Symfony 4 much smoother.
How Was the Developer Experience Enhanced?
Developer tooling got a significant boost. The most visible change is the improved web debug toolbar and profiler, which now provides more detailed and actionable information.
The dotenv component was enhanced to handle multiple .env files and environment variable overriding more intuitively. The console component also saw improvements, including better command listing and more descriptive error messages.
These tweaks might seem small individually, but together they make the daily development workflow faster and less frustrating. You spend less time configuring and more time building features.
FAQ
Is Symfony 3.4 a Long Term Support (LTS) release?
Yes, Symfony 3.4 is an LTS release. This means it will receive bug fixes for three years and security fixes for four years from its release date, providing a stable foundation for long-term projects.
How does the new directory structure in 3.4 differ from previous versions?
The new structure moves configuration to config/, templates to templates/, and public assets to public/. This is a shift from the old app/Resources pattern and is the default for new Symfony 4.0 projects, introduced in 3.4 for forward compatibility.
Should I use the new Messenger component instead of RabbitMQ or similar bundles?
The Messenger component provides a unified, framework-native API for sending and handling messages. It can work with existing transports (like Doctrine, RabbitMQ). It's a good choice for new projects or to standardize messaging in existing ones, but mature projects with complex setups might not need to migrate immediately.
What is the practical impact of the "defaults" key in service configuration?
It reduces duplication. Instead of repeating autowire: true or public: false for every service, you define it once under _defaults. This makes service definitions much shorter, cleaner, and easier to read and maintain.
Are there any breaking changes in Symfony 3.4 I should worry about?
No, Symfony 3.4 maintains full backward compatibility. The changes are additive (new features) or come in the form of deprecation notices. Your existing 3.x application should run without modification, but you'll see deprecation warnings for features slated for removal in 4.0.