DEV Community

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

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

Robert Schleinhege on December 05, 2022

Many web developers choose PHP frameworks because they are reliable and efficient. Although there are several PHP frameworks available, Laravel and...
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 :)