Laravel vs Symfony

Laravel vs Symfony

Facebook
Twitter
LinkedIn

[yasr_overall_rating] Over 126 people have rated [4.4/5]

Laravel vs Symfony

Today, when starting a new project, one of the key decisions is to pick the right framework. It’s become hard to imagine building a complex web application from scratch nowadays without one.

Many popular languages for web development have their “default” framework, such as Ruby on Rails for Ruby, or Django for Python. However, PHP has no such single default and has multiple popular options to choose from.

According to Google trends and GitHub, the most popular PHP frameworks are Symfony with 13.7k stars and Laravel with 29k stars (at the time of writing this article).

In this article, I am going to compare these two frameworks and show you how to implement simple, everyday features with each. This way, you can compare the code of real-life examples side by side.

This article presumes strong PHP skills and an understanding of the MVC architectural paradigm, but no previous experience with Symfony or Laravel is required.

 

Firstly, choosing a good PHP based framework proves to be the right building block. This makes app development a breeze. In the article, we are particularly going to look at two PHP frameworks, Laravel and Symfony.

We are going to compare each other, and score them, and also declare a winner.

In summary, you will choose the right framework for you and your product.

 

PHP framework similarities

Both Symfony and Laravel give cross-platform capabilities. This helps to speed up the development of your application. The scaffolding of the application helps you to define the structure. The plugins extend the ability to add features to the application.

Comparing from a baseline perspective, both options give a good start to developers. What differentiates between the two, depends on the particular and specific application. Also, one the developer needs is related to this.

 

PHP framework differences

In this case, it is easiest to define the differences by categorizing similar features and the benefits. Once they are categorized, multiple questions pop up to ask about them. Answer these questions and the best option for your specific requirement should distinguish itself.

 

Popularity

Firstly, you should not choose a framework based on popularity alone. However, there are some benefits that a large user base would bring to the framework.

Laravel is the most popular PHP framework. But Symfony also ends up on the number two spot.

When a framework is popular, there exists a huge amount of training resources online. The sheer amount of tutorials that exist online for Laravel is just outnumbered that of Symfony. Though Symfony has extensive documentation. The resources are not as extensive as Laravel has.

Laravel: 1

Symfony: 0

 

Performance

In older versions, Laravel performed better than Symfony.

However, with improvements in Symfony 4+, Laravels offerings have shrunk down close to nothing. The performance gains that Laravel used to boast might not be there anymore.

In summary, if you are using the latest version of any PHP framework, you will get the highest performance. Therefore, there is no change in score.

Laravel: 1

Symfony: 0

 

Modularity and Scaling

Above all, Symfony provides reusable components, which gives more amount of modularity. It is able to organize the code in a much cleaner way. Therefore, makes it a greater fit for larger and higher complicated projects. This is the reason why many experienced developers prefer Symfony over Laravel.

Additionally, Laravel’s strength revolves around MVC based apps. Once you go beyond MVC, laravel is unable to help you.

Using Laravel to be set up and running will leave your Symfony cohorts to dust. In this case, a set of prebuilt dependencies that you shall need. However, if you are building a larger application, picking and choosing your dependencies will help you. Therefore, this makes the application easier to enhance and scale. As a result, for this section, the point goes to Symfony for providing flexibility and modularity.

Laravel: 1

Symfony: 1

 

Templating Engine

In particular, PHP itself is a templating engine.

However, providing additional templating engine provides more advanced templating with less syntax.

Using additional templating engines will help you to keep the business logic in PHP. The presentation logic is kept in the templating engine.

In summary, Symfony provides Twig as the default templating engine, Laravel provides a bit more.

Therefore, Laravel’s templating engine Blade has a lot to offer. Blade provides advantages over Twig. Particularly, it allows for code re-usability that does not exist in Twig. Additionally, Laravel brings in Lumen, a sub-framework for building APIs and microservices.

Laravel: 2

Symfony: 1

 

 

Recommended Read: Laravel VS CakePHP

 

 

Database support

In particular, both Laravel and Symfony provides Object-Relational Mapping(ORM) for data access. With Symfony, Doctrine handles ORM, while Eloquent handles ORM for Laravel. In summary, with ORM  the data manipulation becomes much simpler in either framework

There are a number of database related differences between the two frameworks.

Let’s look at the databases that are supported by each:

 

Laravel VS Symfony

Database Laravel Symfony
Drizzle X
MySQL X X
Oracle X
PostgreSQL X X
SAP Sybase SQL Anywhere X
SQLite X X
SQLServer X X

As you can see Symfony provides additional options. Therefore, Symfony wins this one.

 

Database Migrations

Using Symfony, database migrations are done automatically. They just need simple definitions for the fields in the models. So this seems like a quick win. On the other hand, database migrations are manual for Laravel. They don’t require defining the fields.

 

Data Modeling

Particularly, with Laravel accessing data requires more knowledge of SQL. This is not the case with Symfony, although you require a repository function with each call.

On the other hand, Eloquent tends to tie up your application to your database schema design. Changing a column could result in changes throughout your codebase. Doctrine as well as Symfony, by extension, uses a mapper pattern. You are able to delineate between your DB schema and your business objects and logic.

Taking all of this into account, Symfony wins this one.

Laravel: 2

Symfony: 2

 

Also Read: Laravel vs Lumen

 

Laravel VS Symfony

Laravel is a better choice if:

  • This is your first experience with the framework, as it’s easy to learn and has a simpler syntax and better learning materials.
  • You’re building a startup product and checking your hypothesis, as it’s good for rapid application development and Laravel developers are easy to find.

Symfony is the best option if:

  • You’re building a complex enterprise application, as it is very scalable, maintainable, and well structured.
  • You’re building a migration of a big long-term project, as Symfony has predictable release plans for the next six years, so it’s less likely that there will be any surprises.

 

Final Score

It all comes down to personal preferences and your needs. If you require that application scalability, then go with Laravel, if you want modularity and flexibility then go with Symfony. We hope that you liked this article Laravel vs Symfony 2020 / Symfony vs Laravel and if you found this useful then do check out our other blogs as well.