DEV Community

Cover image for Decision Time: PHP Framework Dilemma
SyntaxSeed (Sherri W)
SyntaxSeed (Sherri W)

Posted on • Updated on • Originally published at blog.syntaxseed.com

Decision Time: PHP Framework Dilemma

My freelance business has grown, and reached a critical decision point for my future development. I've been puzzling over this for a while - why not puzzle it out in public!?

I need to pick a PHP framework. Or maybe not pick one. But my dilemma is kind of unusual. I'd love the opinions of other experienced PHP devs! But hear me out, my situation is a bit unique.

Unhelpful Metrics

Extensive research has given me endless comparisons of Laravel vs Symfony & others, using completely useless (to me) metrics like:

  • Number of GitHub stars.
  • Google search popularity.
  • Job postings.
  • Number of StackOverflow questions.
  • Millisecond differences in speed.
  • Etc.

These comparisons aren't helpful. Let me explain why.

My Situation

I build websites & web applications for small to medium sized businesses. Most start as a basic website with a contact form, Google Map, and that's it. Many never grow past this. Some eventually add custom dynamic elements. Say a work-order status page. A searchable directory, etc. A few have grown bigger.

But, and this is key... I also provide hosting, so ongoing maintenance is on me. I don't deliver a project & wash my hands of it. I make future text changes, fix bugs, add things & keep it running - for sometimes many, many years. My oldest PHP project in production is over 10 years old!

Over time I will end up with DOZENS of these projects to take care of.

I don't have the luxury of one, beautiful application to keep front-of-mind.

And so, stability over time is a key. Easy upgrades are key. This is why WordPress replaced my internal CMS for clients who fit that use-case: one-click upgrades baby! That's gold.

Until recently I was using a simple, custom MVC framework that I built. Most of my existing projects are on that. But it's over 8 years old, pre-Composer, and time for a new direction. To give that old workhorse some credit though- it has needed almost zero updates over that time (likely due to stagnating on PHP v 5.6).

I have a few months of experience & learning with Laravel, it's nice. But ongoing updates are a concern. Backward compatibility isn't a priority for Laravel. And it's overkill for 90% of what I do.

I've built a few things with SlimPHP.

I'm intrigued by Symfony because it starts as a micro-framework & grows with you. Awesome!

I'm also considering sticking a few stable Composer packages together for a light version of a 'framework' that will cover all but my few large projects. Maybe Slim is exactly that?

Maybe 90% of what I do doesn't need a framework at all.

It all boils down to not wanting to regret my choice 10 years from now. My youngest child starts school next year & when that happens I'll be throwing my efforts into my business full time. Between now & then I want my ducks in a row & to do the necessary learning.

TL;DR - My Priorities

  • PHP based.
  • Stability over time.
  • Well documented & clear upgrade process.
  • Grows with my needs over time.
  • Doesn't break backward compatibility on a whim.
  • Ok to have one option for small stuff and one for big projects.

Thoughts?

Do you have experience maintaining several framework-based projects over time? What do you use? Is it painful?

Am I crazy for thinking everything even needs a framework?

How does your company handle the time spent maintaining & upgrading a client's project? Do you bill them for the time? Offer a Support Licence with a monthly fee that covers this type of work? Bundle it in the hosting fee?

Thanks everyone!

--
Originally Published on Blog.SyntaxSeed.com

Latest comments (79)

Collapse
 
jrushlow profile image
Jesse Rushlow

I was in the same boat as yourself. I've used my own MVC Framework but after a while, I felt it would be best to start relying on a more robust solution.

I compared Laravel and Symfony, and ultimately ended up using Symfony. Laravel's interpretation of semver, scares the hell out of me. I built an app based on Symfony 4.3 a while back and have recently upgraded it to Symfony 5 without a hitch. The whole process took a matter of minutes. Granted the app was not that sophisticated. I was also fortunate that some 3pl bundles I was using were updated within a few days of Symfony 5's release...

I'd recommend giving Symfony strong consideration.

Thanks geeShoe

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W) • Edited

Thanks! I very much agree with you.

It's funny that Laravel moved to SemVer recently, but that just means all their packages are getting a major version bump almost every update. I also heard that even core packages that weren't changed are getting the version bump to keep them all at the same version num. Strange.

I want stability. At least save up the BC breaks & pack them all together in a major release less often. It feels like they still don't get the point.

Which sucks because I want to use Laravel. It's beautiful & the ecosystem is great.

Collapse
 
abunch profile image
Al Bunch

I may be a little late to the game, but...full disclosure I have about 20 years experience with PHP, I've used Cake (large oil & gas company and large computer manufacturer), CodeIgniter (also at o&g company), and for the past 4-ish years Symfony (3.x) for a smaller HR company (we're now migrating to 4.x and it's pretty painless). None of what I've developed would equate to a small site with little traffic. We're (small dev team) tasked with keeping things current/up to date and Symfony has been the easiest to update relative to the other frameworks (very few bc breaks). With the built in debugger, extensive logging, and well written framework error messages, pinpointing a problem is much easier in Symfony than the other frameworks though that may have changed over time.

It's completely possible to wire your ORM or heavy business logic into a Twig template if you work at it in Symfony - but you shouldn't. Symfony doesn't so much enforce good coding as it encourages it. You can bloat up your controllers with business logic, forms, and all sorts of junk or you can spin your business logic off into services, put your queries in reusable libraries, write a mess of reusable twig filters, and get your controllers down to a scant dozen or so lines of code.

I only have about 2 months of experience with Laravel - just long enough to know it's just too tempting for me to wire things incorrectly "just to test something out". I know I'd be coming back in 6 months to try to fix that little shortcut and it would be pinned in place by 20 other things that grew off of it in the meantime. Laravel to me seemed like it would be a great framework to knock together a quick prototype/proof of concept.

My vote would obviously be for Symfony - it's not really a beast to set up, you can spin up a default Symfony project in a minute or two with composer. In a few more minutes you can have a workable prototype - a few views and matching controllers, some queries/repositories/tables using Doctrine. Symfony 4 with Flex is really nice. I imagine you could say most frameworks are overkill if you're doing simple websites but I'd still use Symfony - if the site starts to grow you've got the ability to bolt on all sorts of stuff, if not, you're good where you are. Look into the Symfony LTS versions - read up on their release processes, backwards compatibility promise, how frequently they release, etc. symfony.com/doc/current/contributi...

Good luck with the decision if you haven't already made one.

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

Thank you. This was a very nicely detailed reply. And very much in line with the conclusion I came to as well.

Collapse
 
jdforsythe profile image
Jeremy Forsythe

I've never used Symfony so I can't speak to that. But having written sites in PHP from scratch, with Laravel, with Angular + Laravel + Lumen, I've never been happier since switching to Node.

As far as longevity, the Angular + Laravel + Lumen app has been in production for years and it's not terrible to maintain from a code perspective, but any deviation from the norm was a headache. I can throw some pointers your way if you decide to go that route.

The tooling 5 years ago also isn't what it is now and if I started today it may be easier.

But I just enjoy the experience so much more in the JS / TypeScript ecosystem. Pick the level of abstraction you want and go from there. I only touch PHP today because I have to maintain things.

Collapse
 
whiteman_james profile image
James Whiteman • Edited

Straight up fark php!!
Fark docker!!
Fark k8s!!
I have developed with both laravel and symfony (which is the best)

Choose a cloud provider and build server less. I choose AWS
Cognito user pools
Amplify
Appsync (graphql)
Dynamodb
Lambda functions
Greengrass
IoTAnalytics
Sagemaker
S3
Quicksight
Build this with a framework.... Hahahaha I'll see you in 2080, at which time you'll be dead or uploaded to the cloud

Collapse
 
fulopattila122 profile image
Attila Fulop • Edited

The biggest problem I see is not Laravel vs. Symfony. You want 10 years of backwards and 10 years of forward compatibility. Do you really want to use the same thing for 20 years?

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

I don't want that at all.

Collapse
 
phpandcigars profile image
PHP and cigars

Well, my awnser would be this: dev.to/phpandcigars/why-i-choosed-...

Collapse
 
silviuctinvoicu profile image
silviu

Start with the domain,have conversation and learn about the domain, take a look at architecture,try to decouple your domain from infrastructure/framework or if you go cqrs/es understand libraries or framework that facilitate that. The frameworks are good for things that everybody does like cruds or helping you with some infrastructure like database or http, but won't help you with your domain,only learning and storming ideas(together with clients/domain experts) will do. Frameworks may help you cook something fast but won't help when customization will come into your way if of course you are coupled with the framework.

Collapse
 
philliprichdale profile image
Phillip Richdale

Do you really need a framework? You have one in WordPress. 180+million installs does have some weight. I use WP+PHP for my work and rarely do I miss anything "frameworky" that WP doesn't offer.

If you absolutely positively need a framework on top of WP just take one of the big ones - it really doesn't matter at all. Cake, Symfony, Laravel. Pick one. Laravel is basically Symfony in better looks, Cake has its own thing going but is a veteran and very well put together.

Good luck and welcome to the choice effect. :-)

Collapse
 
comir profile image
Raffael Comi

If upgradability is your main concern, I can recommend Flow, the Framework especially developed for Neos.
They have a strong focus on maintainability and upgradability and provide migrations which can even upgrade your custom code.

Collapse
 
abovetempo profile image
Daniel Coleman

I recently transitioned my Linux webapp from Laravel MySQL and Apache with angular frontend as separate app to .net core MySQL and Apache with angular as separate app. Coding with .netcore and Angular 8 in vs code is really awesome and it's all open source and can run on linux

Collapse
 
evanburg profile image
Evan Burgess

If you don't like all the extra stuff that Laravel provides, you should check out Lumen maybe!

Collapse
 
dafriend profile image
dafriend • Edited

It might be interesting to look at the new version of CodeIgniter which has just launched the first Release Candidate for version 4 of the framework.

It's been extensively reworked and has been brought up to date in terms of modern PHP practices. It's still has a small footprint and great performance. It's flexible and not opinionated about the best way to do things. Documentation Here.

Collapse
 
nyanchev profile image
Nikola Yanchev

Hey you can have a look at codeigniter, 3 is a bit old nit they are on the verge of releasing a new version, think rc1 just got public

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

I have one project on an old version of Codeigniter. It was my first use of a 3rd party framework & I recall it being a nice experience. I also love the name!

But I'm not confident enough in Codeigniter's longterm outlook to really consider it.

Collapse
 
adamkirk profile image
adamkirk

It really depends on your goals and how much you care about the architecture/maintainability of your codebase over time...

I'm a DevOps engineer working with teams of php Devs. If it were up to me we'd be using symfony, but the Devs need to make their own choices (and possibly mistakes) and chose laravel.

The biggest reason for choosing symfony over laravel for me is that, although laravel is alot quicker to build with (there's alot less 'plumbing' to be done). It makes it far too easy to write code that is very hard to maintain, and has poor separation of concerns.

For instance, the facades and app->make function in laravel allow you to utilise any service, be it a database, a queuing system, or a redis cache from ANYWHERE in the application. Without highly experienced developers keeping an eye on this, you'll tend to see things like database calls being made from blade templates. This is horrible to debug and pretty much destroys the concept of MVC (which most php Frameworks are designed to follow).

Also, eloquent is a huge pain due to model class structures not being very explicit. What I mean here is that if I wanna know which fields exist in an object, I can't just look in the class definition and see the class properties; I end up having to look in migration files to see the name of the public property that needs changing (if your lucky there may be a few arrays, with some strings in which are the property names). Also if you have alot of business logic associated with your models such as when I set X value on this model it should affect its y value, you're gonna have to create a lot of wrapping services to encapsulate logic which should actually exist in the model itself (normally in setter methods). Otherwise you find yourself duplicating logic all over the shop.

Dont get me wrong, laravel can be an awesome framework to use, but you need to learn to ignore some of the more standard practices in laravel...and use doctrine instead of eloquent. Seriously, I can't state enough how much better doctrine is.

The way I always try to explain why I'd choose symfony over laravel is this: symfony requires more plumbing than laravel, but this plumbing is a necessary evil which helps ensure a healthy codebase. When using symfony you have to think alot more about 'how do I access that service from here', and then do it through proper channels (i.e. dependency injection) as symfony only really allows things to be done in certain ways, whereas in laravel you can just use a facade from anywhere.

I know I'm slating laravel alot here, but I do see laravel being suitable for an agency that will throw a site up somewhere and then forget about it...if you're gonna be maintaining it yourself forever and are bothered about a well structured codebase, symfony is the one.

As a bit of background, I've worked on large scale e-commerce sites in both symfony and laravel. The symfony site, was pretty standard symfony (with some problem areas mostly due to poor oversight and rushjobs; not the framework). The laravel one required quite alot of restructuring to meet the requirements for speed of delivery whilst keeping clean code (try implementing Domain driven design in laravel;not fun). And oh yeah, you can probably guess, we replaced eloquent with doctrine.

Collapse
 
fulopattila122 profile image
Attila Fulop

No framework can help lame developers from writing terrible code.
I've seen people without experience tricking Java & Spring. It was blood and sweat, but they did it :)

Collapse
 
lovekrissh143 profile image
Krissh Victor

A Great saying.

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

This right here is a fantastic comment. This is very helpful, and mirrors some of my own thoughts.

Thank you kindly for taking the time to write this. I think this really tipped the scales for me toward Symfony.

😁👌

Collapse
 
hasselbringjm profile image
JMHasselbring

I go for laravel nowadays... more and more people look for laravel developers on indeed, linkedin, upwork, freelancer etc.