What Is New in Symfony 3.0
Symfony 3.0 is a major release that removes all deprecated features from the 2.x branch, resulting in a cleaner and more modern codebase. This version enforces new standards and streamlines development by cutting legacy code. The table below summarizes the key changes.
| Category | Key Changes |
|---|---|
| New Features & Components | Introduction of the Ldap and Form PhpRenderer components. The SecurityBundle's firewall configuration is simplified. |
| Improvements & Changes | PHP 5.5.9 becomes the minimum requirement. Standardized directory structure (e.g., AppBundle). Removed the assetic package. |
| Deprecated Code Removal | All features deprecated in Symfony 2.x have been completely removed. This includes the getRequest() method in controllers and the form_theme tag. |
| Backward Compatibility | Projects that have already removed deprecation warnings from their code will have a smooth upgrade path. Others will need to address these issues first. |
Why Did Symfony 3.0 Remove So Many Features?
The primary goal was to clean up the framework by removing every single feature that was marked as deprecated during the 2.x cycle. This practice keeps the codebase maintainable and encourages developers to use modern, supported APIs. In practice, this means a leaner framework and faster execution for applications that are already updated.
This cleanup impacts areas like templating, forms, security, and routing. For instance, the old getRequest() method in controllers is gone in favor of injecting the Request object. The form_theme tag in PHP templates was removed, pushing developers to use the form_theme configuration instead.
What Are the New Minimum Requirements for Symfony 3?
Symfony 3.0 requires PHP 5.5.9 or higher. This allows the framework to use features like the ::class constant and generators, leading to more robust and readable code. Some components have even higher requirements; for example, the new Ldap component needs PHP 5.5.19+.
Directory Structure Standardization
The release standardizes the directory layout. The app/ directory now only contains configuration, logs, and cache. All source code, including controllers, entities, and bundles, now lives under src/. The AppBundle is placed in src/AppBundle by default.
Which Bundles and Packages Were Removed or Changed?
Several bundles and packages were removed or became optional. The Assetic package (assetic/assetic) is no longer included by default, reflecting the shift towards using Webpack or similar tools for asset management.
Security Bundle Simplification
The SecurityBundle's configuration was simplified. The firewalls configuration no longer requires the security.context service to be explicitly set, reducing boilerplate in your security configuration files.
FAQ
Is upgrading from Symfony 2.8 to 3.0 difficult?
If you've been diligently fixing deprecation warnings in your 2.8 project, the upgrade is straightforward. The main task is removing any usage of deprecated features that are now gone. The Symfony documentation provides a detailed upgrade path.
Why is Assetic no longer included?
The web development ecosystem moved towards more powerful front-end build tools like Webpack and Gulp. Symfony 3.0 reflects this by making asset management a concern for these dedicated tools, not the core framework.
Can I still use PHP templates in Symfony 3?
Yes, PHP templates are still supported. However, the deprecated form_theme tag for PHP templates was removed. You must now configure form themes globally or per controller instead of inline in the template.
What happened to the getRequest() method in controllers?
It was removed. You must now inject the Request object into your controller action method as an argument, which is a cleaner and more testable practice that was already recommended in 2.x.
Are there any new components I should start using?
Two new components were added: Ldap (for LDAP integration) and Form PhpRenderer (which extracts PHP rendering logic from the Form component). Check if your project needs LDAP functionality.