Ask HN: What PHP framework would you choose if you could start over?

35 points by kluck ↗ HN
Suppose you work at a company and a new project comes up with no reponsibility whatsoever to reuse existing code. The task is to create a web application based on a framework with the following features:

- GPL-compatible licence

- developed by community, not a company

- framework and application are written in PHP

- should be extendable via plugins/addons/extensions etc.

- cms features are included (or via addons)

- deployment features are included

- no php code in templates

- payment and shop features are included (or via addons)

What framework would you choose?

Also, feel free to share experience with web frameworks even if you don't know any framework that might fit.

59 comments

[ 3.1 ms ] story [ 125 ms ] thread
Laravel

It's got the most active PHP community, and sufficient online support from documentation and community. You could also start with Spark and let them handle the boilerplate.

https://spark.laravel.com/

Does it match _all_ the criteria above?
Wow.... What a sense of entitlement. You ask HN a question and then jump down a commenters throat for potentially not meeting ALL of your requirements (Some of which are not clear at all or, at least with the information you provided, don't make sense at all: templates without code in them aren't templates, they are static HTML pages...).

Laravel is a great suggestion and has been made multiple times in this thread, it may not meet every last bit of your criteria but to disqualify it for that reason would be ridiculous. There is literally NO framework or CMS that exists that is going to meet _all_ your requirements.

My comment was not meant to "jump down" on anyone. Sorry for the misunderstanding. It was a simple question (also because the Laravel answer did not go into that much detail).

The reason why I added "templates without code" is because I have seen too much abuse of php code in templates to even consider doing that again.

While you are probably right that there might not be (but who knows for sure...) one framework that meets all the criteria, it is still worthwhile to ask the community for suggestions.

What's the scope/role/purpose of your app?
Responsive UI for non-web system. But noone knows what the future brings so we'd rather build this thing on a solid base.
Laravel I believe matches most criteria above. Symfony would be a second choice.

The driven factor though is community. This is key. No matter how good your framework is if there is no community behind it to create, innovate, talk about it and so on.

Worked with Zend framework 2, which I believe is a great PHP framework, but the community is stagnant. We often have to create modules (libraries) for things most frameworks already had (ie, Symfony).

* - developed by community, not a company *

This rules out Symfony and Laravel which are imho the only sane options in php.

Why do you need this requirement ?

Actually, Symfony has corporate backing with SensioLabs, if that's the company you are referring to, but Symfony is also largely developed by the developer community. You can submit patches, feature additions and they can be merged if there is a consensus on the quality and usefulness of the patch.

I think Laravel has the same development model.

I guess he's meant an open source solution, which both Laravel and Symfony are.
This ensures that the development of the framework is not guided by commercial interests.
As someone with positive experience in Ruby on Rails, I would choose (and have chosen) Laravel. Specifically version 5.1 which is the current LTS release.

It does not have a CMS module nor an ecommerce add on as far as I'm aware, but depending on the complexity of your requirements they might not be difficult to do yourself (eg just a few pages of editable content with a few wysiwyg editors here and there, and a straightforward shopping cart / checkout experience using Stripe for payment).

If you absolutely need plugins for all the things in your list, I think Symfony is probably your best bet -- but it is less of a cohesive framework than Laravel, so you'll be mixing and matching things and doing a bit more work on your end (but possibly worth the tradeoff).

> It does not have a CMS module

octobercms.com is based on Laravel

October is based on Laravel, but it is not a module that you can "plug in" to an existing Laravel site -- hence it does not meet the OP's requirements.
I would choose Symfony. I believe it matches all of the above criteria.

And it has:

- amazingly simple upgrade paths, backwards compatibility guarantee on minor and patch releases

- regular, non BC breaking, updates and new features

- corporate backing

- large ecosystem of "bundles", which are Symfony's addon system

- cli tool for scaffolding, debugging and more

- strong conventions that help keep code structure clean when you are in a team of 2+ members

Code Igniter and Drupal are my choices.
Worked on Drupal for half year and I swear that I will never touch this piece of shit.

CodeIgniter is only good for very simple website. It miss a lot of functions that a sophisticated framework has (eg Laravel)

Drupal, in whichever flavors people are still using (5, 6, 7 or 8) is quite bad. Avoid, Avoid, Avoid.
I'd argue Laravel and Symfony's development are tightly coupled to a single person / company (Taylor Otwell / SensioLabs). If CMS & ecommerce are a big portion of this project I'd easily pick WordPress. The only requirement it fails to meet is "no php code in templates". WordPress meets all the other criteria and it is generally great for spinning up a MVP.
Wordpress is good if you need posts/blog-like site, but if you're going to scale up to something really huge like Groupon did, you'd be better off with a custom framework w/ full control, better caching, etc. -- Wordpress is a hog on resources, and very easily hacked as well. My laravel sites all perform light years better/faster.
Depending on projects I'd choose between Laravel & WordPress. I like the simplicity of these 2 systems.
I realize that this is not in line with the PHP requirement, but hear me out:

I would use Ruby on Rails.

I have transitioned from using Drupal to Symfony2 (sometimes with Sonata) to using Ruby on Rails, and let me tell you, everything is indeed greener on this side. The tools are better, the language is easy to learn and it is mostly sane. The framework is amazeballs, I am not even kidding. Writing tests is actually fun. In general, I am a much happier developer with Ruby on Rails. I would also dare to say that RoR makes me a lot more efficient as well.

In Symfony I'd frequently get stuck in finding a workaround for some weird bug, which just doesn't happen that much anymore in Rails...

I have to agree. Having gone from using Ruby/Rails to the PHP side and its whole ecosystem, if you want an MVC framework I would say just use Rails or Django. Laravel is somewhat painful by comparison.

Wordpress is quite fine for most things though.

yes it is really good to use this
Yii2[0] is simple, elegant and powerful. Unfortunately it does not adhere to:

> - no php code in templates

But it does abstract the template/view nicely.

On a personal note and this will most probably get me down votes. I would not recommend anyone to use PHP frameworks. But I understand real-life factors like current skill set, dev availability, etc.

[0]: https://github.com/yiisoft/yii2

I agree, and I've used Laravel too. Yii is built and designed by someone who has written frameworks before and understands how to do it right. The creator wrote the Prado framework, then wrote Yii from the ground up.

Laravel definitely has all the hype, but Yii has been around much longer and is better architected imho. It does have a slightly steeper learning curve and isn't as instantaneously easy to use at first, but it's worth the effort.

I would not recommend anyone to use PHP frameworks.

I haven't created anything in PHP for years. However, I used to create stuff with Yii and I was pretty happy with it.

My feeling was that if you use a proper framework and you're a decent programmer, PHP is actually not that bad.

Why do you advise against it?

I wouldn't use laravel because it seems that the guy who made it hasn't yet earned my respect as the dictator of the project. It seems backwards compatibility is a real issue for his framework. He's no torvalds. I can't trust him to not break things.
What functionality got broken?
Definitely Laravel. My company switched over at the end of last year and it's been great. I think it meets all your requirements except for `no php code in templates`, though I think you'll always have to have some minimum template code for looping/displaying data in any framework.
fyi Laravel does not use PHP code in templates. It has its own templating language called "Blade" (which I personally don't like, so I swap out Twig instead).
It's good to know that the templating engine can be exchanged.
You can use straight PHP in blade templates if you want. Even with blade tags, for the most part it's still just PHP.
So you're looking for a CMS - Wordpress and friends - clone, and not a framework?
Right. This shouldn't be understated. If a CMS is a must, why isn't Wordpress being considered?
We had some experience with Wordpress and from the list of features, it fits the bill almost. Almost because we found the templates were very messy.
A lot of people here are saying Laravel. I agree. I haven't done a new site in PHP in a long time but I did jump back and try Laravel for a bit and was impressed.
Symfony 3 has worked out very well for us. I don't have experience with lavarel or zend.
If you have a chance to rewrite everything it's time to high tail it out of the PHP ecosystem my friend.
Most people in my company have mostly been working with PHP and thus it would be too much of a break with the past to switch languages.
Use the framework that the team likes and wants to learn.

You're going to get the best value from a framework that is matched well to the team's current skills and ambitions. Consider:

* Team currently writes procedural code versus Framework requires understanding of Functional Programming or Object Oriented Programming

* Team writes quickly and loosely versus Framework requires developers to code methodically and carefully (perhaps because it has less "out of the box" features and more "flexibility". Security is a good example here.

* Team likes technical challenges versus Framework makes coding routine boilerplate and boring.

etc.

> What framework will you choose if you could start over?

Anything that is not Python or Ruby or NodeJS based, i had so many problems and nigthmares with Django/Flask/RoR/bottle.py/web2py/Meteor/etc.

> He say PHP Framework...

Anything but CakePHP, Zend or Code Igniter maybe Laravel or Slim.

There is a lot of Node.js frameworks out there. Meteor is not really representative of them. Did you have issues with other Node.js frameworks too?