In the past months, the two most popular frameworks within the PHP ecosystem received important updates: Laravel & Symfony.
Laravel was recently updated to version 5.6. This new version has some attractive innovations such as Argon2i algorithm support, implemented with PHP 7.2; new Blade view engine directives, as well as component system improvements and the addition of a package that shows errors from the CLI of Laravel. You might also like: How to deploy Laravel application on AWS EC2 the right way
Symfony had an even greater update since it went from version 3.4 to 4. With a remarkable code simplification, Symfony 4 promises to be the fastest PHP framework on the market these days.
Both frameworks are developed under an MVC architecture model, making use of advanced concepts and patterns from Object Oriented Programming. The elegance that these frames have allows you to manufacture almost any kind of project, that’s why most developers prefer them. Therefore, this time we focus on showing the differences between them and its advantages. The importance of knowing the characteristics of each framework is the key point to decide the best one to develop and maintain our project. Learn how to scale to million users with AWS Laravel applications.
Symfony is the framework developed by Fabien Potencier from SensioLabs and since its release in 2005 has been the most robust PHP framework. The components that are part of this make it a reliable and agile frame.
Symfony 4 simplified many things. Here are some of the most notable features of the new update:
Previously, the way to install Symfony required a custom installer, and sometimes annoying. Now, it allows us to install it using a common Composer command:
composer create-project symfony/skeleton project_name
When creating a new project with version 4, Symfony begins with the structure of a microframework. It removes most of the components that in previous versions are included by default.
Since Symfony now begins as a microframework, the SensioLabs team developed a Composer plugin called Symfony Flex, which is a simplification of the commands “require”, “update” and “remove”. Basically, it allows you to install Symfony modules using an alias, besides automatically registering it in the frame, avoiding the need to do it manually.
- Simplification in the directory structure.
- The bundles were removed.
- The way of managing development environments was simplified, now you can do it by employing a global variable instead of a file for each one.
Laravel is a project created by Taylor Otwell, developed mainly by him with some help from the community. Laravel has earned a lot of attention from developers because of the great variety of its components and packages. Another significant aspect of Laravel is the versatility with which it is encoded making it much easier to learn and use.
Laravel is continuously updated approximately every six months. Here are some of the new features of version 5.6:
It is a package developed by Nuno Maduro for showing errors in a striking way when you use your application through the command line. The design of these errors is something similar to those shown in the browser.
The new version of PHP (7.2) includes a new encryption algorithm called Argon2i. Laravel added support for this algorithm from its encryption component. Now we can encrypt the passwords within our application with a newer and more secure algorithm.
Error log (Logging)
As part of the development, it is essential to have a registration system to find errors faster. Laravel already had one by default, which was creating them through files. It could add new drivers for this and now, they added the support to send the errors to a group of Slack, which is excellent.
- New Blade view engine directives.
- Improvements in the Blade view engine components.
- Commands for the generation of controllers for an API.
- Administration of channels for web sockets in a similar way to the routes.
Laravel vs Symfony
It is clear that each frame fulfills some requirements better than the other. Both offer very useful aid for development. Both are high-quality frameworks.
Like everything, deciding to use a frame instead of others is always the decision of the developer. It must be emphasized that each frame adapts differently, based on the requirements of each application.
In our opinion, although its performance is not better than Symfony, Laravel is better. Why? Laravel has a reasonably soft learning curve, plus a huge community willing to help. It is not necessary to be an expert to program with it. It also gives you the freedom to create a structure based on your needs. Its large number of components and packages makes you focus on what is most important to you: the business logic of your project.
However, this does not mean that I hate Symfony or that I think it is not good. Quite the opposite, it is an excellent framework for larger projects (even Taylor, the creator of Laravel knows this). With its new update, the creation of microservices will be exceptional. And if you have good bases regarding POO, you can do a lot with it.
When deciding on which of the two is better, always analyze your needs and how each one can adapt better to your project. Finally, do your best to program with both frameworks, I assure you that you will not regret it.