Anyone being this or that way related to PHP web development has definitely heard about these two frameworks.
Symfony and Laravel are much-and-often talked about, and, mostly, in a good way. So, what is the right way, to choose the best out of good? This is the topic of new Umbrella article.
Why have we decided to speak today about Laravel vs Symfony comparison?
ON THE ONE HAND,
currently, all PHP frameworks are in high demand. This can be explained by the fact, that PHP programming language has been enjoying significant popularity with the development environment within the previous few years.
PHP (Hypertext Preprocessor , originally Personal Home Page Tools), is a language that started as a set of tools aimed to develop personal web pages. And today it is still acknowledged as the tool, mostly used by many developers to build interactive and user-friendly web apps.
As you see from the diagram above, PHP occupies the stable leading position as the language, most frequently used by sites, and is successfully applied for creating high-load sites.
PHP was used to build such famous projects as:
ON THE OTHER HAND,
both Laravel and Symfony are intended to accelerate development and ensure good performance. In this context, each of them offers its own approach and possibilities to the developer.
From this standpoint, Symfony PHP framework appears to be some stability pillar.
Throughout its existence, Symfony 2 has turned into a kind of classic decency in PHP development. The framework has gained the high stability level and continues improving.
Meanwhile, Laravel is a fairly young framework that is actively developing now. Its creators have chosen a different approach and followed a new path.
The start was taken from Symfony.
Laravel is created on its basis and inherited much from its predecessor.
Symfony is, in general, distinguished by being composed of various components. The components can be added and replaced or can be used in projects created with the frameworks other than Symfony.
Many of the components, initially designed for Symfony, are used in Laravel, which anyway does not mean it to be a copy of Symfony.
FRAMEWORKS SPECIFIC FEATURES
To install the framework we need to load Symfony Installer. For this purpose the following command shall be performed in any appropriate console application:
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
Console application is an application that allows interacting with the computer using text commands (instead of graphic interface, the user got used to).
As soon as the components installation is complete, we create new Symfony app using the following command:
$ symfony new my_project_name
Laravel installation is the same. The installer is loaded with the dependency manager for PHP – composer. For this purpose, perform the following commands in the console application:
$ composer global require “laravel/installer”
$ laravel new my_project_name
This means that in both cases the developers took care to ensure, that installation and start of the framework will not require much time, and we can get a ready-to-use set of tools with a minimum effort.
Symfony supports a wider set of formats: PHP, YAML and XML. The possibility is available, to choose either the most appropriate for the given project (for example, XML is used as standard by many major companies) or the one preferred by the developer according to his/her experience and qualification.
Laravel supports one format only – PHP. This excludes any choice issue. But, in general, this format is sufficient, especially for the beginner-developers. They do not need to learn any other formats, but for PHP.
Function of any app presents the following process:
Any request to the server shall be first checked for conformity to various rules (whether the user has access to the information requested, what data format is sent, etc.)
You want to read more detailed information on the page and click See details…, this means you send the request to go to the more detailed content.
And in case the access to the content is allowed to the authorized users only, the request will be denied, and you will be redirected to the authorization/registration page.
For this purpose, Laravel uses middlewares – levels of verification to be passed by HTTP request on the way to an app. All requests to your app are checked against certain criteria. If they fail to pass, they are rejected.
In Symfony the similar process runs using kernel events method. The events to be sent to the app are considered. And these events can be limited using filters.
From the technical point of view (at the code level) the approaches differ, but in both frameworks, the process is provided for in the original functionality. It should be noted, that the inexperienced developer will probably find Laravel approach easier to be implemented.
Zumic – built using Laravel
As a template engine (required to process HTML templates to create ready-made HTML pages), Symfony uses Twig by default, while Laravel applies Blade.
Both template engines do offer the required features:
The difference is that Twig possesses more rigid structure and does not provide for inserting PHP code directly into the template. At the same time, it allows using filters.
From this point of view, Blade is more flexible. It makes possible to write the code in the template, and it can be easily and endlessly extended.
Both frameworks offer fresh solutions for easy databases handling, not directly, but through the abstraction layer.
Due to this, the following is possible:
For this purpose Symfony applies the third-party solution – Doctrine set, while Laravel possesses its own Eloquent library.
Their difference is as follows:
BlaBlaCar – built using Symfony
Symfony and Laravel apply similar approach in terms of services.
Service in PHP language means any object that is designed and in charge for a specific purpose, which is a complete performance of some universal task.
Sending e-mails out of the app.
Symfony differs through its rigid control over the structure and does not allow deviating from the accepted code pattern. Often this appears to be an additional challenge for the developer, but it allows the app to stay flexible and extensible to the maximum extent.
Laravel does not limit the developer through any rigid boundaries. It often provides for the possibility to cut corners and arrange things bypassing the pattern. In this case this is the developer, who is to make a decision, whether he/she will maintain and keep the structure or not.
The beginner developer is recommended to start with Laravel.
This framework was originally tooled for being easy-to-use and convenient for developers. Laravel creators tried to embody all the best features and characteristics in one. And judging by the fact that since 2015 Laravel has been called the most popular PHP framework, they did a stellar job.
Laravel has a short learning curve. This framework is full of magic. That is, its functions, for the most part, are just running, but there is no need to go into details as to how and why they run exactly this way. Just trust the framework and its high standards. The framework’s structure and main processes are all simple and easy-to-understand.
Symfony is much harder to be mastered, and this requires more time. Along with the framework itself, the developer needs to learn specific features of the programming language and technologies used to put into effect its possibilities.
iKeyless – built using Laravel
No doubt, this Symfony vs Laravel 2017 list can be continued. We just wanted to draw some examples showing their different approach to development.
Meanwhile, in terms of support and updates, both frameworks have equal pros:
Surely, in the foreseeable future they will continue making developers happy and their life easier.
And now let’s imagine the situation when you may need to choose between Symfony and Laravel:
Do you need an app, and want to know how your future product will be developed?
Suppose, for any reason whatever, you have chosen PHP as a programming language for the future product. In such a case Umbrella team, as a rule, relies on one key criterion, in order to make the right choice:
PROJECT SPECIFIC FEATURES
Symfony is recommended for the following:
In this case, these are reliability and stability that do matter. And Symfony framework review shows that Symfony is far from being unpredictable. Besides, Symfony has a ready release plan for the next six years. Therefore we should not await any “surprises” on the part of the framework.
Laravel is recommended for the following:
In any case prior to making your choice of the toolset, analyze together with your developers the complete info about the future product (target audience, functions, expandability, etc).
This mean, start with defining WHAT you do. And then decide HOW to do it.
Any questions on these PHP framework, their specific features, and use? Contact us right now!
Create long-term relationship built on result & experience.
Tell us about your business ideas and goals and we will contact you.