What’s new in Symfony™ 4 ? Clever Age team give you a summary of Fabien Potencier’s conference in Ho Chi Minh City

  • #Frameworks & development
  • #Technical & Entreprise Architecture

Published on Updated on

Clever Age Asia attended this event given by Fabien Potencier on the 8th of November in Ho Chi Minh City, Vietnam. The founder and lead developer of Symfony™ was there to present the framework and the new features coming with version 4.

About the talk

First of all, for those who still don’t know about Symfony™: it’s a very popular PHP framework that is used by hundred thousands of web applications and many others popular open source projects such as Laravel or Drupal. Symfony™ is the leading PHP framework in Europe and quite popular in America, but still not well known in Asia. This talk by Fabien Potencier is the opportunity to leverage the framework in Asia.

Even though Symfony™ 4 was released a year ago and that most features are known by the Symfony™ community, it’s still not the case in Asia, where the PHP community is much smaller than in the rest of the world.

During the talk, Fabien explained the main features of the new version by combining both slide presentations and a live demo for the audience.

Comparison with the previous version

Symfony™ 4 is an improved and lighter version of Symfony™ 3 without all the obsolete and unnecessary features/plugins. Sensio wants to expose it as a micro frameworks so it allows developers to enable only what they need. The idea behind is to improve the performance of your application and to become more scalable for different project sizes. You want to build a small API or a big web application, you can use Symfony™ 4. Meanwhile, Sensio stopped supporting Silex, their old micro framework.

How to migrate

For those who used the first version of Symfony™, we all remember how difficult it was to migrate to the version 2 due to the big difference between the two of them. Since v2, they have made the migration painless and they provide a full documentation to help developers to upgrade their project. From 3.4 to 4, the most difficult part is to incorporate Flex to follow the right directory / configuration structure.

Symfony™ Flex and recipes

Fabien talked about Symfony™ Flex, a whole new way to manage your PHP applications. It will automate installation, update and removal of numerous bundles that are popular among the Symfony™ community. Symfony™ Flex is available since from 3.3 and above. Even though Flex is optional, it’s highly recommended by its founder.

Messenger component

The messenger component is a new way of organizing an application structure and business logic. It aims at bringing some asynchronous tasks and features to Symfony™, which was lacking in the previous version. If you’d like to learn more, we suggest you to read Matthias Noback’s blog post https://matthiasnoback.nl/tags/command%20bus/ because the Command Bus Pattern is a game changer in modern PHP application and we strongly recommend using it.

Autowiring of services

Before Symfony™ 3.4, developers had to configure services manually in order for the application to know which one to use for dependency injection. Thanks to autowiring, Symfony™ can automatically detect what service to use based on their ids and type-hint. Therefore, autowiring is a great way to automate configuration in Symfony™ without further effort for developers.

Symfony™ 4 is fast … really fast !

When it comes to performance, Symfony™ is one of the best. Fabien showed a performance comparison of modern php Frameworks. Symfony™ 4.x emerges as the fastest PHP framework, against Laravel 5.x, Zend 3.0 and CakePHP 3.x.

You are already using Symfony™

As Fabien mentioned, what is a better way of promoting a framework than showing who uses it ? Well, guess what, every major PHP Framework and Application that you can find in the market uses parts of Symfony™. For instance, PIM and CRM application such as Akeneo, already uses Symfony™ libraries. In the E-commerce ecosystem, Magento and Prestashop also use parts of the framework. And it is the same for other PHP frameworks like CakePHP and Laravel.

What would you choose another slower framework that uses parts of Symfony™ when you can directly start building with Symfony™ ?

What we are really using

The most part of the talk was a real time live presentation of Symfony™ 4 and how the framework was improved to get started even faster. But, when you are working on complex applications and real business problems, some of the brand new features are not as useful as they seem. Let’s break down the key features.

Flex

As we said earlier, Symfony™ Flex helps you get started really fast when building an application, and auto configure external libraries and bundle for you. Over the past years, we have been working on multiple Symfony™ 2/3/4 projects, and we have never used the library standard configuration. We always have to customize or change it to fit the project needs. So, even if flex and the recipes do the job for us, we still have to edit the configuration files manually.

When upgrading to Symfony™ 4, migrating to Flex is not mandatory. But if you have a look at the new updated documentation and cookbook for Symfony™ 4, every example uses Flex. It means that at some point, when we’ll have to migrate to flex if we want to understand the documentation more easily. Or, if a new junior developers joins the project, he might not be able to work without flex. So, even though flex is not mandatory, everyone will migrate at some point.

Behind the “magic” commands

Symfony™ is known to have a very efficient Command Line Tool (The command component). And it is true, using Symfony™ Console, you can create Controllers, Entities, Services, Listeners etc. very quickly. It is a very powerful tool when you start learning Symfony™. But for experienced developers, theses commands are never used as we prefer to create the files by ourselves. Once again, this feature is a great way of getting started Symfony™ but not useful for experienced developers.

Directory structure

Symfony™’s directory has been evolving throughout time. Their goal is to provide a framework with a developer friendly and Unix-like structure. Therefore, Symfony™ 4 comes with less sub directories and some directories have been renamed to reflect the community’s expectation. The notion of “bundle” is now not recommended to split the application logic because a “bundle” is supposed to be reusable as a standalone piece, which is not the case of most of the applications. Therefore, it has been removed from the framework. Below is a comparison between the previous and the current version of Symfony™.

Conclusion

This Symfony™ meetup was aimed to introduce the framework to the asian community, Fabien spent most of the time talking about the new fancy features such as Flex, recipes, CRUD generator to make your own API in a few minutes.

Clever Age has been in Asia for a couple of years now, and we can feel that the PHP community here is still pretty young, compared to Europe or America. But the changes introduced to Symfony™ 4 and highlighted by Fabien during the talk are a good way of bringing more companies and developer to use the framework for new projects. Even though these new features won’t drastically change the way we develop now, we strongly believe it will bring more developers into the PHP and Symfony™ community soon.


  • Framework

  • PHP

  • Symfony

  • Symfony

  • symfony 4