Learn What’s New in Symfony 3.1

by Shahroze Nawaz  July 13, 2016

Symfony 3.1 has been released and experts consider it the most stable version of the framework so far. To bring the readers up to speed with the framework, I have started a  series of blogs on Symfony 3.1 covering basics such as Up And Running With Symfony 3.1 and To-do App Using Symfony 3.1

What's new in Symfony 3.1

In this blog, I will highlight the new features and components introduced in the latest release of the framework. I will discuss the major changes and updates introduced in this release. You can visit the GitHub pull request links by clicking the pull request code at the end of the description:

The following is a quick list of the areas that have received updates/revisions.

  • LDAP
  • YAML
  • Process
  • Serializer
  • Console
  • HTTPKernel
  • Form
  • Security

Let’s take a bit detailed look at each of the above component so that you could read about the update and get the GitHub pull requests.

LDAP

Lightweight Directory Access Protocol (LDAP) is an open industry standard used for assessing and maintaining distributed directory information service over the network. When it comes to information sharing, LDAP is trusted by every stakeholder. Symfony introduced LDAP as a component in the 3.0 version, which provided integration with Symfony security component. In version 3.1, LDAP gets some major updates.

  • Option to configure all available LDAP options for connection [18725]
  • Check whether an entry attribute exists [18492]
  • Added default service name for the security components [18387]
  • Add write support for the LDAP component [17817]

YAML

YAML stands for “YAML Ain’t Markup Language”. It is used extensively in Symfony to convert YAML strings to PHP arrays and vice versa. YAML is mainly used for its configuration files, blueprints, and in page settings. YAML is a very popular component and has received some major updates.

  • Introduced flags to customize the parse behaviour [17730]
  • Added option to dump objects as maps [17728]
  • Parsing the !!php/object tag is now deprecated [17462]
  • Added support to parse and dump DateTime objects [17836]
  • Added support for parsing the !!binary tag [17863]

PROCESS

The Symfony Process component executes commands in subprocesses. The component takes care of the subtle differences between the different platforms when executing the command.The Process component provides an object-oriented abstraction on top of proc_* functions to execute independent processes in PHP. It has been updated in Symfony 3.1 .

  • IteratorAggregate to stream output is implemented [18414]
  • Added support to Traversable Input [18350]
  • A callback is now allowed whenever the output is disabled [17427]

SERIALIZER

Symfony comes with a Serializer component that converts objects into specific format like JSON, XML,YAML, etc. Serializer allows encoders to only deal with encoding specific formats into arrays and vice versa. The Serializer service is not available by default and you need to activate it from config file. This component has received updates in Symfony 3.1.

  • Added forward and redirection detection in WDT (HeahDude) (17589)
  • Added more information in the security profiler (javiereguiluz) (17887)
  • Added status code to search form (oktapodia) (17125)
  • Added HTTP return code in the Ajax request list table (kucharovic) (17540)

CONSOLE

The Console component makes it easy to create beautiful and testable command line interfaces. This component allows creation of command-line commands which are then used to perform specific recurring tasks from console such as cron jobs, imports, or other batch jobs.  Before Symfony 3.1, commands could not be registered privately. However, in this release, the component has received several updates:

  • Private commands are allowed to be registered privately [18101]
  • Added ApplicationTester support to test stdout and stderr [17255]
  • Added non-auto column width functionality [17761]
  • Added truncate method to FormatterHelper [16652]

HTTPKernel

The HTTPKernel component works using request-response model. It uses the “eventdispatcher” component to convert request into response through a structured process. Every HTTP web interaction depends on request and its related response. Usually, a PHP snippet is used to read the request and carry out relevant action. In Symfony 3.1, HTTPKernel received some minor updates including:

  • Deprecated passing objects as URI attributes to the ESI and SSI renderers [17611]
  • Added the kernel.controller_arguments event [18440]
  • Added an ArgumentResolver with clean extension point [18308]

FORM

Forms are often the UI that the users see on a website. Forms are used to get user input for CRUD operations. Symfony uses HTML forms and PHP generated forms generated using arrays and APIs. The Form component focuses on processing data to and from the client and the application. The Form component has some updates including:

  • LazyChoiceList and DoctrineChoiceLoader are optimized [18359]
  • Deprecated form types as services [18356]
  • Deprecated the “choices_as_values” option of ChoiceType [16994]

SECURITY

The Security component provides a firewall within and outside of the webapp to protect it from security threats and exploits. From authentication to certified login, this component ensures that the developers have all the tools to integrate security into the webapp. An important option is the creation of custom policies and security rules. Mainly it has four subcomponents; security-core,security-HTTP,security-csrf,security-acl used for security purposes. Some of the major updates for Security component in Symfony 3.1 are:

  • Use auth trust resolver to determine anonymous in ContextListener [18211]
  • Added new TargetPathTrait to get/set the authentication “target_path” [17714]

These are some of the major component updates in Symfony 3.1. I hope that you have found the description useful. You can also view the complete guide and changelog at the Symfony’s official site.

FINAL THOUGHTS

Symfony 3.1 is the latest and the most stable release of the framework to date. Although Symfony 3.2 has also been released, it is still unstable and require further work. I recommend that you start using Symfony 3.1 for your next development project. If you need an introduction to the framework, you could follow my tutorial series on Symfony. Another good resource is Symfony’s Living on the Edge blog series.

Please leave a comment if you discover any issues or have a query.

Happy Coding!

Start Creating Web Apps on Managed Cloud Servers Now!

Easy Web App Deployment for Agencies, Developers and E-Commerce Industry

About Shahroze Nawaz

Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He’s always in search of new frameworks and methods to implement them. Besides his coding life, he loves movies and playing soccer with friends. You can email him at shahroze.nawaz@cloudways.com

Stay Connected:

You Might Also Like...

  • It’s a good start article.

    But i not agree with you, that “is the best choice to start a new development”.
    If the new development is planned to release soon, in fact, 2-3 months, i’m agree; for more development time, it’s better move to next version, 3.2
    http://symfony.com/doc/current/contributing/community/releases.html#version-history
    3.1 03/2016 05/2016 01/2017 (8 months) 07/2017
    3.2 09/2016 11/2016 07/2017 (8 months) 01/2018

    And you have support to 2018.

    Another reason to make a choice, it’s the bundles that you need; then, you have to choice the symfony version in relation with the version supported for the bundles that you need.

    In resume; medium – long term developments, i think that the better choice it’s 3.2 (and, in a very long term dev, migrate from 3.2 to 3.3, or to 3.4).

    Regards.

    • Shahroze Nawaz

      Hye Jose thanks for giving feedback but I believe for beginners its best to use 3.1 because it’s a current most stable version. although 3.2 is in development and new components are introducing on daily basis but once 3.2 stable we recommend developers to update on it