Symfony 4 is the new Boss in PHP Framework 
Tags: symfony, php, composer, doctrine
Published: 2019-10-06 11:13:05

---
title: Symfony 4 is the new Boss in PHP Framework 
published: true
description: if you ever think that Symfony is not the right framework for you, this is article can change your mind. Or if you ever like Symfony 3/2, you will definitely appreciate this one. 
tags: Symfony,PHP,Composer,Doctrine
cover_image: https://miro.medium.com/max/3880/1*fr7_twoEgSkSBrRv50qEeA.jpeg
---
## Table Of Contents
 *[Introduction](#Introduction)
 *[Component](#Component)
 *[Form](#Form)
 *[Translation](#Translation)
 *[Bundle](#Bundle)
 *[Doctrine](#Doctrine)
 *[Annotations](#Annotations)
 *[Migrations](#Migrations)
 *[Services](#Services)
 *[Logger](#Logger)
 *[Performance](#Performance)
 *[conclusion](#conclusion)

### <a name="Introduction"></a>
<h1> Introduction  </h1>

![alt image](http://igm.univ-mlv.fr/~dr/XPOSE2014/Symfony/architecture.png)
Symfony is a full-stack  web framework, built with a lot of reusable set of standalone  PHP components that solve common web development problems.

### <a name="Component"></a>
<h1>Component </h1>
![alt text image](https://codereviewvideos.com/blog/wp-content/uploads/2017/02/getting-started-symfony-workflow-component.jpg)
Component they are the core of the framework, they are libraries  that contains a lot of useful reusable code like 
-Form
-Finder
-Filesystem
-Asset
-Mailer
-Routing
-EventDispatcher
-Translation
let's take some of them as example 
<!-- ![description](https://raw.githubusercontent.com/gdahboy/_dev_community_post_images_/master/Screen%20Shot%202019-09-26%20at%2017.06.37.png) -->

### <a name="Form"></a>
<h1>From</h1>
![alt text of image](https://symfony.com/legacy/images/jobeet/1_4/10/form_flow.png)
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 ... } 

### <a name="Translation"></a>
<h1>Translation</h1>
![](https://www.uvdesk.com/wp-content/uploads/2017/07/blog-translation-in-symfony.png)
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. 

### <a name="Bundle"></a>
<h1>Bundle</h1> 
![alt](http://www.galitein.com/ga-content/uploads/2017/12/symfony2-distributions.jpg)
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 

### <a name="Doctrine"></a>
<h1>Doctrine</h1>
![alt text of image](https://symfony.com/doc/2.0/_images/doctrine_image_3.png)
Symfony doesn't have it's own object mapping library . it used Doctrine Library , which used by many PHP frameworks like laravel  and  zend.

### <a name="Annotations"></a>
<h1>Annotations</h1>
![alt image ](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2016/06/14692642771466426077download.png)
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 !!

### <a name="Migrations"></a>
<h1>Migrations</h1>
![alt text image ](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/07/Data-Base-Migration.jpg?fit=900%2C741&ssl=1)
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 !!

### <a name="Services"></a>
<h1>Services</h1>
![alt of image](http://anjanasilva.com/wp-content/uploads/2014/05/4.png)
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 ? 

### <a name="Logger"></a>
<h1>Logger</h1>
![alt image](https://symfony.com/doc/current/_images/web-interface.png)
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 . 

### <a name="Performance"></a>
<h1>Performance</h1>
![alt image](https://www.cloudways.com/blog/wp-content/uploads/50-1000.png)
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 

### <a name="conclusion"></a>
<h1>conclusion</h1>
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 .