Introduction

I am very excited about new Symfony release. Lot’s of things changed. This post puts everything in one place and highlights the most important changes.

Dependency Injection component

The dependency injection component had many changes. To improve RAD the service autoconfiguration was added as well as getters autowiring and getters injections. In my opinion, the most sexy change is adding the optional class for named services. It allows you to create a service without adding the direct class name.

services:
    AppBundle\EventListener\UserManager:
        tags:  ['kernel.event_subscriber']

In your controller/service, you can just retrieve it using the simple syntax

$this->get(UserManagerInterface::class)->save($user);

Full list of the changes with explanation you can find here.

Logs

Who likes upgrading libraries/frameworks? Nobody? That’s what I thought. Symfony added to his awesome developer toolbar a new tab with all deprecations.

DI tab

New components

WebLink component

Symfony supports the HTTP/2 even better and lets us link resources so they may be prefetched to increase loading of the websites.

Lock component

This new component was experimentally added to Symfony 3.3 but was removed for now and will have his second chance in Symfony4.

Dotenv component

Thanks to this component, loading from .env files is now built-in into Symfony. It helps to develop and manage configuration without deploying on production.

Webserver bundle

Do you like the PHP built-in server? Symfony uses it for a while and decided to move the functionality to a separate bundle.

Configuration

This component had not so many changes. The changes that are worth stressing are: adding support for defining custom YAML tags and reading config with glob patterns. The way we can get project’s root is simpler now.

Other improvements

They are many of other improvements. Most of them are listed below:

Security bundle improvments Redesigned exception pages (they are more pretty now!) Routing works fasterer It is simpler to get flashes in templates Workflow improvments got some improvements, too like new twig function workflow_has_marked_place() or a new entered event. Kernel build method was added to make creating apps without own bundles easier Search in dumped content – if you want to be able to search in your dumps, do not be a lama and use VarDumper component!

Incompatibility notice

Symfony follows backward compatibility promise, but from time to time they must break it to fix a security issue. This time it happened and trusted_proxis configuration key was removed.

Summary

That’s not all. I highly recommend following their blog and Fabien’s, too. I personally cannot wait for the Symfony 4 which changes the way we work with the framework.

Symfony 4 is comming. It will change the way we work with this framework, drops HHVM support.

UPDATE: The “trusted proxies” configuration was reverted because it caused problems with deploying applications with different proxy configuration on test, stage and prod env.

About the author

Bartłomiej Kiełbasa

Bartłomiej Kiełbasa

Hi! I'm Bartek. I'm a PHP developer but other languages are not scary to me. My hobby is security and I try to learn as much as it's possible how to not be hacked. I'd ike to know how things work. After hours I like playing Dota2 and watching Dragon Ball :) If you will have any question, feel free to ask.