What Is New in Symfony 2.3
Symfony 2.3 introduces a set of new components, significant improvements to existing features, and the usual batch of deprecations to prepare for future versions. The focus is on enhancing developer productivity and framework capabilities.
| Category | Key Changes |
|---|---|
| New Components & Features | Web Link component, DOM Crawler enhancements, Lazy Loading Form Validator, Expression Language in Security Voters. |
| Improvements | Form Type Extensions, better Translation fallbacks, Yaml component rewrite, Security component refinements. |
| Deprecations | Legacy form features, legacy Security Voter interface, some Yaml component methods, legacy Validation API. |
| Bug Fixes & Security | Various fixes across the codebase, including security-related patches for the HttpKernel and Security components. |
What new components were added in Symfony 2.3?
The standout addition is the Web Link component. It provides tools for managing links between resources, which is crucial for modern web performance techniques like HTTP/2 Server Push and resource preloading. You can use it to add Link HTTP headers easily.
Another notable update is within the DomCrawler component, which gained the ability to filter using CSS selectors directly, making it much more intuitive for front-end developers to work with. This is a practical upgrade from the previous XPath-only approach.
How did forms improve in this release?
Form handling got smarter with the introduction of lazy validation. The validator is now only initialized if a form actually has validation constraints, which can give a nice performance boost in larger applications with many simple forms.
Form Type Extensions became more powerful. You can now use FormEvents::PRE_SUBMIT to modify form data before it's bound to the underlying object. This is a game-changer for complex, dynamic form logic that depends on user input from previous fields.
What changed in the Security and Translation components?
The Security component integrated the Expression Language directly into voters. This allows for more complex and dynamic authorization rules to be written concisely within voter classes, moving beyond simple role checks.
Translation fallback mechanisms were improved. The system now provides more predictable and consistent behavior when a translation is missing in a specific locale but exists in a fallback locale, reducing surprises during internationalization.
Were there any major internal rewrites?
Yes, the Yaml component was completely rewritten from the ground up. The new implementation is more robust, faster, and fixes numerous edge-case bugs from the older version. In practice, your existing YAML files should just work, but the underlying engine is now much more reliable.
This rewrite matters because YAML is the de facto configuration format for Symfony applications. A more stable parser means fewer deployment headaches related to config file parsing.
FAQ
What is the most important deprecation I need to watch for in Symfony 2.3?
The form system deprecations are critical. Using the setDefaultOptions method in form types or the legacy Security Voter interface will trigger deprecation warnings. You should start updating these to use configureOptions and the new voter interface to ensure compatibility with Symfony 3.0.
Does the new Web Link component require HTTP/2?
No, it doesn't. The component simply provides a standardized way to create Link HTTP headers. These headers are useful for HTTP/2 Server Push, but they are also used for other purposes like resource preloading or prefetching in any HTTP version. The component is protocol-agnostic.
How does the lazy form validator improve performance?
It avoids instantiating the entire validation subsystem for forms that don't have any constraints defined. If you have a simple contact form without validation or with very basic HTML5 validation, this removes overhead. The gain is most noticeable in applications that render many different forms per request.
Can I use CSS selectors with DomCrawler in functional tests now?
Absolutely. This is a major usability improvement. Instead of writing complex XPath queries like //button[@id='submit'], you can now use the more familiar button#submit. It makes your test code easier to write and read, especially for developers more comfortable with CSS than XPath.
Why was the Yaml component rewritten, and should I be concerned?
It was rewritten to fix long-standing bugs, improve performance, and create a cleaner codebase. You shouldn't be concerned about breaking changes for standard YAML syntax. The new component is a drop-in replacement that behaves better. The only changes required are if you were using some of its internal methods directly, which were deprecated.