Cover image for Symfony 4 is the new Boss in PHP Framework

Symfony 4 is the new Boss in PHP Framework

gdahboy profile image gdahboy ・4 min read

Table Of Contents



alt image
Symfony is a full-stack web framework, built with a lot of reusable set of standalone PHP components that solve common web development problems.


alt text image
Component they are the core of the framework, they are libraries that contains a lot of useful reusable code like
let's take some of them as example


alt text of image
the form component is a very useful tool, the general idea behind is to create an object that represents a form in that object you can specify every detail related to form in front-end {design, behavior...} and backend {field, entity, form relation ... }


this component is really useful you can use it in order to internationalize your application. instead of rewriting much text, you can create some sort of Dictionary. So your Application will be smart to detect when and what language to be used every Request.


Bundles are a great way that Symfony Developer's use to write reusable code. let's take an example , You are creating an E-commerce Web application . in this type of Application there's a lot fo common aspect like : Facture , Product , Product-Basket , Product-Categories , Client , Coupons , third party library of payement 💰 💴 💵 and a lot more . you will need this entity each time + integration of some of libraries . Bundles has giving us the ultimate Solutions . we create an e-commerce Bundle and every time we have the e-commerce we can include it with it's entity , Repository , Interfaces that will be automatically integrated to the new template thanks to Twig


alt text of image
Symfony doesn't have it's own object mapping library . it used Doctrine Library , which used by many PHP frameworks like laravel and zend.


alt image
Annotations are a great way to describe your data into php classes , you can specify every attribute as table column in your database . you can also add some parameters to the field like required , unique and other constraint related to size , type , range and you can even create your own parameters . this is only the start , through annotations you can represent entity relationships and lot more !!


alt text image
migrations is very similar to VCS , every time you make an update to your data structure you create a migrations (in git language we call it 'commit') and you can migrate throw migrations using version that stored in your database . it's really a cool 😎 thing i used it a lot !!


alt of image
we have covered a lot yet , but we have maybe reach only 5% of Symfony. So how can this framework manage all this library 📚 together. How can he manage to initialize a lot of classes without being worried about performance? Well through Services this is possible by initializing core functions once in all the platform and re-use this instance every time. Let's s an example of Mail Component Service .
So there's an object called Container that already contains many services . to make things more simple , let's say that services are some instances of class library 📚 . Implementing Services is really easy you can do that through controller or in services configurations in services.yaml . Once i have used Services to automatically logout every user after a 30min of an active session i created a class with 4 arguments in it's constructor that give the functionality of ending user's session . then i have add the class configuration in services.yaml file with all it's 4 argument .So symfony will automatically initiate the class and use it automatically every time he need it . Cool 😎 isn't it ?


alt image
Logger is a very cool part of symfony. it gives us a great tool to check for session , cockies , routes , sql requete , performance , reponse time ... and every details you would ask for . so go to your configuration files active the dev mode and here you go , you got your interface ready .


alt image
one of the biggest concern when we care about before we start using any language or framework is performance . PHP is one of the greatest scripting language in web development , but to be honest is not that great if we look


thank you for reading my article . i really recomand Symfony for complex project or a group project . it can be hard at the begging but you will find very easy when you understand the core concept of it .

Posted on by:

gdahboy profile



A Cloud-architecture Student interested in DevOps iaas platform and WebService


markdown guide

Well, I do agree that Symfony 4 is "the boss" of frameworks at the moment, but definitely not because of all the stuff listed.
In fact, the stuff listed in the article are the reasons why Symfony 3 became Symfony 4, by stripping down most of the features included by default in the framework in an effort to make it leaner and faster.
The advantage of Symfony 4 is that you can strip it down and make it lighter (both in disk size and loaded functionality), but even so it still performs poorly in terms of sheer speed and memory footprint (look at Ubiquity 2 or Symlex - just don't mistake it for Silex).

The world has already moved away from fullstack frameworks (even backend monoliths would be frowned upon when starting a new project). If I were to make a new API project, the stack would look more like:

  • PHPDI - dependency injection container
  • thephpleague router
  • monolog
  • thephpleague plates (for templating, significantly faster than twig - if you need server side rendering)
  • Doctrine (speaking of which, the Doctrine items you listed are Doctrine advantages, not Symfony advantages)
  • roadrunner as the PHP application platform (if you haven't tried it, you should) OR symlex (which is still a fullstack framework, but with true modularity)

The reason being that the first 3 are PSR-compatible components, whereas Symfony needs an additional translating service to normalise its requests/responses in a way that allows you to take advantage of its modularity (also, if requests/responses aren't PSR-compatible you can't use an application platform like roadrunner for true concurrency & paralellism).


The article meant to be for beginners not for seniors ... thanks for the comment it add more to our subject


I used to hate Symfony 4 coming from Symfony 3. Nothing was preinstalled like I was used to, you had to use Flex to install things. Now that's one of my favourite parts about it. Start barebones and add what you need, and everything just plugs in and works! It's fantastic! :)


sorry to forget mention it . Flex is one of the greatest advantages of symfony 4 add to that the new architecture and project model of symfony 4 make it greater to use .


I agree. The messagebus and the workflow components are two I've found really useful as of late, and thanks to Flex only a "composer require workflow" away :D As said, I hated it at first, but it has made things both easier and leaner. Good post! Symfony is indeed the Boss :)


Hi @burak ,

You mean to work with RabbitMQ etc? If so Symfony Messenger can be used to work with queues.


RoadRunner has integrated Queries, you don't even need a framework for it anymore.


Roadrunner is just a replacement for nginx+php-fpm pair. You still have to write your own queue implementation in your application, you won't have features like failed jobs, delayed jobs, max attempts, expirations, chained jobs etc. You have to waste many hours.

It is not just a replacement and it does have most of the features you mention. It also have automatic reconnects for queue brokers which it near to impossible to achieve in php. Check this repo: github.com/spiral/jobs

It can also run queue in memory, so you don’t need any broker.


What does it have to do with Queues?


Great article!
But I think are general advantages inherent in other frameworks such us Yii2 or Laravel (exclude Annotations, but many developers didn't think this advantage, because they confused and complicate writing tests).
Symfony loves for the discipline of writing clean code.
(Sorry english is not my native language)


this article hasn't yet cover everything . there's a lot common in PHP frameworks and we will go through disadvantages with a newer articles .


Thanks for your review! why most frameworks don't make the workspace visualized?


I've been a happy Codeigniter user for years. Tested Laravel at the time but seemed complicated. Now I might be looking again, Symfony included. I want a cleaner template, more powerful ways to build sql queries/searches. We'll see.


i think that the right place is symfony ... well to be honest at first it may seems complex at the begging but when you use to , you will see how great to use it


Nice work friend i like it even i hate php and his frameworks


the idea behind this article is to choose the best framework of PHP frameworks