What Is New in Symfony 2.8 (Summary)
Symfony 2.8 introduces a range of new features, improvements, and deprecations to prepare for the upcoming 3.0 release. This version focuses on modernizing the codebase and adding useful utilities. Below is a high-level overview of the key changes.
| Category | Key Changes |
|---|---|
| New Features | New Process component, LDAP component, LockHandler, PSR-6 Cache bridge, and more. |
| Improvements & Additions | Enhanced DebugClassLoader, new form themes, HTTP status code constants, and new validators. |
| Deprecations | Numerous methods and classes deprecated to be removed in 3.0. |
| Bug Fixes | Various fixes across the Form, Security, Routing, and other components. |
What are the major new components added?
Symfony 2.8 ships with two brand-new, fully decoupled components. The Process component provides an object-oriented interface to execute system commands in sub-processes, handling things like timeouts and streaming output. The Ldap component offers a client for LDAP operations, which is especially useful for enterprise authentication scenarios.
Another significant addition is the LockHandler class, which creates file-based locks for ensuring a command or script only runs in a single process on a given server. This is a common need for cron jobs and background tasks.
How does the caching system improve?
This release introduces a PSR-6 bridge. The Symfony\Component\Cache\Adapter\Psr6Adapter class allows you to use any PSR-6 compliant caching library as a Doctrine Cache provider. In practice, this bridges the gap between Symfony's historical use of Doctrine Cache and the newer PSR-6 standard, offering more flexibility for cache backend choices.
Additionally, several new cache-related classes are added under the Symfony\Component\Cache namespace, laying the groundwork for a future, more robust caching component in Symfony 3.x.
What form-related changes should I know about?
The Form component gets a new @FormTheme annotation for controllers, letting you specify which form theme to use directly in the controller class. This is a cleaner alternative to calling $form->setTheme() in an action method.
New form themes are also included: bootstrap_3_layout.html.twig, bootstrap_3_horizontal_layout.html.twig, and foundation_5_layout.html.twig. These provide out-of-the-box integration with popular CSS frameworks, saving significant frontend integration time.
Are there new tools for debugging and development?
Yes, the DebugClassLoader is enhanced. It now reports when you try to autoload a class from a case-insensitive file system (like Windows or macOS) with the wrong case, which is a common source of "class not found" errors after moving code to a case-sensitive Linux production server.
The component also provides better deprecation warnings, helping you identify code that will break in Symfony 3.0. This is crucial for a smooth upgrade path from 2.x to 3.x.
What deprecations are introduced for Symfony 3.0?
Symfony 2.8 contains a massive list of deprecations. These are methods, classes, and services that will be removed in 3.0 but still work in 2.8 with a warning. Key areas include the OptionsResolverInterface being replaced by OptionsResolver, changes in the Process component's API, and deprecations in the Form, Validator, and Security components.
Running your application with the Symfony Profiler or using the debug:container and debug:router commands will highlight many of these issues. Addressing them in 2.8 is the recommended strategy before attempting an upgrade to 3.0.
FAQ
Is Symfony 2.8 a Long-Term Support (LTS) release?
Yes, Symfony 2.8 is an LTS release. This means it receives bug fixes for three years and security fixes for four years from its release date, making it a stable choice for long-term projects.
Why is the new Process component a big deal?
Before 2.8, you had to rely on PHP's basic proc_open or similar functions. The Process component wraps this functionality in a clean, object-oriented, testable, and more secure API, handling edge cases like timeouts, signal handling, and output streaming that are easy to get wrong manually.
How do the new form themes work with Bootstrap 3?
The new bootstrap_3_layout.html.twig and its horizontal counterpart provide form markup with the correct CSS classes for Bootstrap 3. You simply reference them in your form theme configuration, and your forms will automatically render with the proper Bootstrap structure and styling.
What should I do about the deprecation warnings?
You should not ignore them. Use the Symfony Profiler's "Deprecations" panel or run your tests with the SYMFONY_DEPRECATIONS_HELPER environment variable set to catch them. Updating your code to use the non-deprecated alternatives in 2.8 is essential for an easy upgrade to 3.0 later.
Can I use the new PSR-6 cache bridge with any PSR-6 library?
Yes, that's the point. The Psr6Adapter acts as an adapter. You instantiate it with any PSR-6 cache pool object (from a library like symfony/cache, php-cache, etc.), and it allows that pool to be used wherever a Doctrine Cache provider is expected within Symfony 2.8.