DEV Community

Cover image for Laravel vs. Symfony: Which Framework is right for your project?
Robert Schleinhege for IONOS

Posted on • Originally published at docs.ionos.space

Laravel vs. Symfony: Which Framework is right for your project?

Many web developers choose PHP frameworks because they are reliable and efficient. Although there are several PHP frameworks available, Laravel and Symfony are two of the most popular frameworks.

Both frameworks have pros and cons, so how can you decide which framework is suitable for your project? In this article, we’ll compare Laravel vs. Symfony and help provide some guidance so you can pick the framework that’s right for your project.

What is Laravel?

Laravel is a PHP Framework that aids with creating web apps by combining components from several different frameworks. In fact, Laravel uses several Symfony components. Released in 2011, Laravel is known for its easy-to-use coding style and features that save time during the development process.

Laravel is often used by small- to medium-sized businesses or startups who need to get their product off the ground quickly.

What is Symfony?

Symfony is both an Application Framework and a set of reusable components. Released in 2005, Symfony is a reliable and mature framework with robust components that create a stable foundation for even large-scale projects. Symfony is also highly modular and flexible, allowing developers to customize their applications depending on the needs of each individual project. It is mainly used for complex enterprise projects.

Laravel and Symfony Similarities

Both Laravel and Symfony are open-source PHP frameworks and share many features, including:

  • Object Relational Mapping (ORM)
  • MVC (Model–View–Controller) Architecture
  • Cross-Platform support
  • CLI Code Generation
  • Multi-user Support
  • Internationalization Support
  • Template Engines

Laravel and Symfony Differences

While the two frameworks share many similarities, there are also significant differences. We’ll discuss some of the most striking differences between the two frameworks.

Performance

According to benchmarking tests conducted by ThinkMobile, the average loading time for websites built using Laravel is around 60 milliseconds, while websites built using Symfony loaded in 250 milliseconds.

Laravel sites load faster because Laravel offers a set of unified APIs for caching views which means the developer can take advantage of faster performance with no extra coding. Symfony can be tweaked to provide faster load times, which takes more time to set up but can be customized to your project.

Scalability

Symfony shines when it comes to scalability. Symfony’s modular system means that applications can be tailored to each specific project, allowing developers to scale their projects as needed. Laravel projects can be scaled with load balancing and route caching with its Artisan command-line tool. Still, you’ll need to plan your Laravel project carefully if you need to scale it to support an extensive enterprise software system.

Database Support

Laravel supports five databases:

  • MariaDB 10.3+
  • MySQL 5.7+
  • PostgreSQL 10.0+
  • SQLite 3.8.8+
  • SQL Server 2017+

With its Doctrine tool, Symfony supports relational databases like MySQL and PostgreSQL and also NoSQL databases like MongoDB.

Both Laravel and Symfony allow for easy data access through the use of object-relational mapping (ORM). Laravel relies on Eloquent, which is based on ActiveRecord, while Symfony uses Doctrine, which follows the DataMapper pattern.

In Eloquent, Models are class extensions that contain all the logic for database access.

Doctrine entities are created as Plain old PHP Objects (POPO). This means that they can be used for various use cases, not just in the ORM context. Because Doctrine uses the DataMapper pattern, database operations can be optimized by queueing them instead of immediately running them.

Both Laravel and Symfony provide support for database scaffolding which creates an Entity Framework model from an existing database.

Templating Engine

Both Laravel and Symfony provide a templating engine. A templating engine allows server-side data to populate an application quickly.

Laravel uses Blade, a simple but powerful templating engine. The Blade templating system compiles all templates into basic PHP code, so there is minimal performance impact on your project.

Symfony uses Twig, a fast, secure, and flexible templating engine. Twig allows the developer to define custom tags and filters and create Domain-Specific Languages (DSL).

Security

Symfony offers robust security features, but they must be explicitly defined, which can sometimes be challenging. Laravel offers more basic security features, but these features are generally more than enough to cover most security issues.

Learning Curve

Laravel is designed to be easy to learn and use. It provides an intuitive API that makes it easier to get up and running quickly. They also offer extensive documentation and community help via their GitHub.

Symfony is more complex, but its modular design allows developers to choose which components they want to use. This allows for more flexibility but also requires a steeper learning curve. Symfony also provides documentation and community help via GitHub.

Popularity

Although you shouldn’t solely pick a framework based on its popularity, it's useful to see how others have put these frameworks to work. A more popular framework also means more developers are available to support your project and a larger community from which to seek help.

This chart summarizes the popularity of each framework.

Laravel Symfony
Number of websites using the framework1 133,610 10,571
G2 Rating2 4.5 Stars 4.5 Stars
GitHub Stars 71.66K 27.7K

1 Source \
2 Source

Summary

Ultimately, the decision of which framework to use will boil down to which framework is best suited for your project. Laravel tends to be the choice of developers who want to develop a web app quickly and easily, while Symfony is used most often by developers who are looking to create large-scale, customized enterprise solutions.

This chart summarizes all the points we’ve discussed in this article.

Laravel Symfony
Common Features
  • Object Relational Mapping (ORM)
  • MVC (Model–View–Controller) Architecture
  • Cross-Platform support
  • CLI Code Generation
  • Multi-user Support
  • Internationalization Support
  • Template Engines
Performance (Average Page Load Speed) 60 milliseconds 250 milliseconds
Scalability Modular system allows developers to scale their projects as needed Scalable with load balancing and route caching
Database Support
  • MariaDB 10.3+
  • MySQL 5.7+
  • PostgreSQL 10.0+
  • SQLite 3.8.8+
  • SQL Server 2017+
Supports relational databases and NoSQL databases
Templating Engine Blade (simple but powerful) Twig (fast, secure & flexible)
Security Robust security; Must be explicitly defined Automatic security for most basic use cases
Learning Curve
  • Easy to Learn
  • Extensive Documentation
  • Large GitHub Community
  • More difficult to learn
  • Basic Documentation
  • Smaller Github Community

Automatically Deploy Your Project with Deploy Now

Whether you use Laravel or Symfony as your framework, Deploy Now offers a convenient toolset to automate builds and deployments for dynamic PHP applications. Deploy Now can automatically create a deployment workflow with GitHub actions and then easily deploy your project to Ionos’ secure infrastructure.

Find out more about deploying your PHP projects via GitHub with Deploy Now or get started with a sample project for Laravel or Symfony.

Top comments (18)

Collapse
 
aerendir profile image
Adamo Crespi

I'm a Symfony developer and started to work recently on a big project in Laravel.

From my perspective, Laravel is more difficult to use than Symfony:

  1. It uses a lot of static methods that make the code practically untestable (until you use overload feature of Mockery, that opens an entire new set of problems)
  2. The documentation is not so extensive and clear: it should be wrote better
  3. Due to its "simplicity", it lead to write worse code.

On the other side, Symfony:

  1. Has a lot of components, but you can have an app up and running in a few hours, also if you start from zero
  2. The autowire and autoconfiguration features make possible to use dependency injection at full power (using composition over inheritance) and having, as a result, a more clean and navigable code
  3. You can configure each and every aspect of the app, from the folder where to put entities to the entire folder structure, completely changing it
  4. No troubles with unit tests, no dirty overload needing: the code is clean and well written

In the end, I really don't like Laravel and its "simplicity": the simplicity is simply a set of bad practices that anyone who would like to learn how to structure code well should avoid (and will, once she/he knows what are antipatterns and which they are).

Collapse
 
roberts profile image
Robert Schleinhege

Thanks for sharing your view on this topic! Why do you think did the Laravel community become larger, dispite the cons you've mentioned?

Collapse
 
aerendir profile image
Adamo Crespi

Honestly? I have no idea: it is absolutely inexplicable to me...

We have to consider some things in how the two frameworks evolved over the years:

At start, Laravel didn't had all the components and features it now has, while Symfony was already a big framework with a lot of packages.

More, only in the last few years Symfony simplified a lot the use of the framework, specifically with the introduction of autowiring and autoconfiguration that made the injection of container useless (indeed, even an anti-pattern) and made defining and injecting services a piece of cake: it is sufficient to implement an interface (before attributes in PHP: now it is sufficient to add an attribute, without the need of an interface).

For me, now there is no reason to use Laravel instead of Symfony, mostly because it is common thought that for enterprise level projects, Symfony is better suited, while Laravel is better suited for MVP or small projects. I don't know if this is really true: I prefer, anyway, to start with Symfony, given I can arrange a small app or an MVP with just a few components (and, thanks to Flex, all is autoconfigured).

I know my point may be considered as the one of a "Symfony maximalist", but I'm seeing this point become real day by day, working with Laravel, without knowing nothing before about it, but knowing a lot about Symfony and the comparison, in my opinion, is in favor of Symfony.

Collapse
 
ismaelmartinezc profile image
Ismael Martinez Cisternas

Nice post!
Just a comment: Scalability is swapped at Summary section.

Collapse
 
amooxakermoud profile image
amooxakermoud

Laravel is the best

Collapse
 
roberts profile image
Robert Schleinhege

Why would you say so? :-) @amooxakermoud

Collapse
 
aswierc profile image
Artur Świerc

I would choose Laravel only for POC or a project full of CRUDs. When it's come to business logic I prefer Symfony.

Collapse
 
roberts profile image
Robert Schleinhege

Can you explain why? @aswierc

Collapse
 
execom99 profile image
Tomas Mikeska • Edited

Laravel does a lot of magic with its syntax (what can be considered as advantage for quickly done demo), symfony is better suited for large (more developers) project, easy to read by Java / .Net developer from my experience

Collapse
 
execom99 profile image
Tomas Mikeska

oh this kind of click-bait articles :)

Collapse
 
roberts profile image
Robert Schleinhege

Seems like it worked in your case ;-)

Collapse
 
execom99 profile image
Tomas Mikeska

exactly :D

Collapse
 
jesusantguerrero profile image
Jesus Guerrero

Nice write up, thanks for sharing I was looking for this kind of updated comparison a month ago.

I think the scalability thing on the side of Symfony is a community myth. I personally feel Symfony is more Design Principles friendly to put in a way, let you set boundaries between code and framework easier to protect against changes.

But in practice it feels that more code is needed to accomplish the same thing.

Collapse
 
roberts profile image
Robert Schleinhege

Thanks for the feedback!

Collapse
 
davorminchorov profile image
Davor Minchorov

The performance benchmarks are out of date.

Collapse
 
roberts profile image
Robert Schleinhege

I'll check it, thanks for the feedback :)

Collapse
 
todaycode profile image
Senior Developer

Depend on your Familiarity!!!

Collapse
 
roberts profile image
Robert Schleinhege

True, but some Devs maybe still have the choice :)