Reading Time: 6 minutes

Symfony has rapidly become the framework of choice for web development apps and projects. Two important reasons behind the popularity are the frequent updates to the framework and the addition of new components. The result is a lightweight framework that is has taken the world by storm.

Already, developers have started to migrate their apps and projects from Symfony 2.8 to Symfony 3.x. I have already discussed the upgrade process from version 2.7 to version 3.0.

The latest news is the release of Symfony 3.2. This release introduces several important areas including caching, profiling and validations processes. I will discuss several important changes that distinguish this update.

How to Install Symfony 3.2 with Composer

The first important update is the way in which Symfony is installed. In several previous articles, I have highlighted Composer as the best option for installing any package, library or framework. You can install Symfony 3.2 with the following SSH command.

composer create-project symfony/framework-standard-edition your_project_name "3.2"

This command will install the stable release of Symfony 3.2. Once the installation finishes, go to the project’s folder and run the following command to start the server.

$ php bin/console server:run

This will start the server and highlight the localhost port in use like this

Open the mentioned URL (http://127.0.0.1:800) in the browser. You will see the new welcome page of Symfony 3.2.

I will now discuss the new components and features introduced in Symfony 3.2.

The All New Workflow Component

Symfony 3.2 has introduced a new component called Workflow . A workflow is the set of processes and procedures that are used in a development environment for automation and production. The workflows are always repeated actions and are scheduled recursively. The Workflow component works with two event features `State` And `Transitions`. To use this component, you should first install it through the following command

$ composer require symfony/workflow

This command will enable the component. To further read about this component, check out these excellent examples by Javier Eguiluz and eleven labs.

Improved Features In Symfony 3.2

Symfony 3.2 has introduced several important changes in key areas of the framework. The complete list is available on the Symfony website . I will now demonstrate several highlight changes with the pull request code.

Related: Symfony 3.3 Features: Components And Bundle

FrameworkBundle

Decreases the number of mandatory dependencies (20097,20075, 20072, 20070, 20067)

New Cache warmers are added (annotations in 18533, validator in 19485, serializer in 19507)

Added support for prioritizing form type extension tags(19790)

Added cache:pool:clear command (19891)

command (19891) Paths changed to relative ones in templates paths cache (19687)

when updating translations domains are allowed to specify (19325)

Changed server:run logs to be displayed by default (19174)

Twig

All Symfony versions now support Twig 1.28.

The Twig cache is now independent to the project root directory (20285)

Refactored Twig extensions to decouple definitions from implementations (20093)

Added Twig runtimes for “critical” Twig extensions (20094)

Added access to token from twig AppVariable (19991)

Serializer

CSV encoder added (19197)

YAML encoder added (19326)

Added support for specifying format for DateTimeNormalizer::denormalize (20217)

(20217) Deprecated SerializerAwareEncoder (18483)

Console

improved support for one command apps (16906)

Added errors display in quiet mode (18781)

Added ability to regress the ProgressBar (19824)

Added ConsoleLogger::hasErrored() (19090)

(19090) Simplified simulation of user inputs in CommandTester (18710)

Centralized input stream in base Input class (18999)

Added support for hidden commands (20029)

DependencyInjection

Allowed injecting ENV parameters at runtime using %env(MY_ENV_VAR)% (19681)

Added automatic detection of definition classes when possible (19191)

Added priority support for CompilerPass classes (18022)

Deprecated access to private shared services. (19146)

Added support for short services configurators syntax (19190)

Fixed ini file values conversion (20232)

Added a trait to sort tagged services (18482)

Cache

Added PDO and Doctrine DBAL adapters (19519)

Added NullAdapter to disable cache (18825)

Added PhpArrayAdapter to use shared memory on PHP 7.0 (18823)

Added PhpFilesAdapter (18894)

Added generic TagAwareAdapter wrapper (replaces TagAwareRedisAdapter) (19524)

Routing

Added support for unicode requirements (19604)

Added support for appending a document fragment (12979)

Added support for array values in route defaults (11394)

Fixed URL generation to be compliant with PHP_QUERY_RFC3986 ( (19639)

Yaml

Moved YamlLintCommand to the Yaml component (19139)

Fixed parsing multi-line mapping values (19304)

Added Yaml::PARSE_EXCEPTION_ON_DUPLICATE to throw exceptions on duplicates (19529)

to throw exceptions on duplicates (19529) Added support for parsing PHP constants (18626)

Allowed using _ in some numeric notations (18486)

VarDumper

Add support for XmlReader (19151)

Add support for Redis (18675)

Handled attributes in Data clones for more semantic dumps (19797)

Allowed dumping subparts of cloned Data structures (19672)

Added $dumper->dump(..., true); (nicolas-grekas) (19755)

(nicolas-grekas) (19755) Added ClassStub for clickable & shorter PHP identifiers (19826)

Added LinkStub to create links in HTML dumps (19816)

WebProfiler Bundle

Switch to VarDumper when displaying data in the profiler (19614)

Added a default ide file link web view (19973)

Added expansion of form nodes that contains children with errors (19339)

Added support for window.fetch calls in ajax section (19576)

PhpUnit Bridge

Replaced ErrorAssert by @expectedDeprecation (20255)

Allowed configuring removed deps and phpunit versions (20256)

Added a triggered errors assertion helper (18880)

Added bin/simple-phpunit wrapper (=phpunit – yaml – prophecy) (19915)

Added support for native E_DEPRECATED (20040)

Form

Changed FormTypeGuesserChain to accept Traversable (20047)

Added a DateInterval form type (16809)

Deprecated using Form::isValid() with an unsubmitted form (17644)

with an unsubmitted form (17644) Added CallbackChoiceLoader (18332)

These are some of the highlights of the improvements introduced in Symfony 3.2. For a more detailed look at all the improvements and changes, check out the official Symfony Announcement.

Support for Symfony 3.2

One of the most important headache for PHP framework users is the duration of support for a particular version. The support for Symfony 3.1 will end in July 2017. After this date, developers should either upgrade or re-code their apps in Symfony 3.2.

For Symfony 3.2, the proposed support roadmap is:

Upgrade from Symfony 3.1 to 3.2

With every new version, developers rush to make their projects compatible with the new release. The problem with new release is that some features and components of the previous releases are no longer supported.

I will now discuss the features that Symfony 3.2 has dropped from the lineup. I will also mention the `require` command for including these packages through Composer.

FrameworkBundle

Removed Dependency Require Command doctrine/annotations composer require doctrine/annotations symfony/security-core & symfony/security-csrf composer require symfony/security-core & symfony/security-csrf symfony/templating composer require symfony/templating symfony/translation composer require symfony/translation symfony/asset composer require symfony/asset Resources/public/images/* files – Resources/public/css/*.css files Inlined in twig Bundle

BrowserKit

Client HTTP user agent has been changed to Symfony BrowserKit.

DependencyInjection

Calling `get()` on a `ContainerBuilder` instance before compiling the container is deprecated.

Form

The Calling of `isValid()` on a `Form` instance before submitting is deprecated:

Previously:

if ($form->isValid()) { // ... }

After:

if ($form->isSubmitted() && $form->isValid()) { // ... }

` DataCollector::varToString()` is deprecated and will be removed in Symfony 4.0. Use the `cloneVar() ` method instead.

is deprecated and will be removed in Symfony 4.0. Use the `cloneVar() method instead. Surrogate name in a Surrogate-Capability HTTP request header has been changed to ‘symfony’.

Before:

Surrogate-Capability: symfony2=”ESI/1.0″

After:

Surrogate-Capability: symfony=”ESI/1.0″

Validator

`Tests\Constraints\AbstractConstraintValidatorTest` has been deprecated and now becomes `Test\ConstraintValidatorTestCase`.

Before:

use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; class MyCustomValidatorTest extends AbstractConstraintValidatorTest { // ... }

After:

use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class MyCustomValidatorTest extends ConstraintValidatorTestCase { // ... }

Setting the strict option of the `Choice` Constraint to `false` has been deprecated and the option will be changed to `true` as of 4.0

use Symfony\Component\Validator\Constraints as Assert; class MyEntity { /** * @Assert\Choice(choices={"MR", "MRS"}, strict=true) */ private $salutation; }

Yaml

Support for silently ignoring duplicate mapping keys in YAML has been deprecated and will lead to a ` ParseException` in Symfony 4.0.

in Symfony 4.0. Mappings with a colon (:) that is not followed by a whitespace are deprecated and will lead to a `ParseException` in Symfony 4.0 (e.g. `foo:bar` must be `foo: bar`).

Conclusion

Symfony 3.2 offers a host of improvements and new features for web development projects. The new version addresses many issues that plagued previous versions of Symfony. Developers must visit the official documentation for in depth look at the new introductions. If you would like to contribute to the discussion, please leave a comment below.

Share your opinion in the comment section. COMMENT NOW

Shahroze Nawaz Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. Besides his work life, he loves movies and travelling. You can email him at shahroze.nawaz@cloudways.com Get Connected on: Twitter Community Forum