Hacker News new | ask | show | jobs
by ardillamorris 5088 days ago
No matter how much PHP is improved upon, until there is a serious contender framework for it like Rails or Django, PHP will continue its route to extinction. Dinosaurs were once big and powerful. They dominated the landscape. They don't exist anymore.
8 comments

No matter how much PHP is improved upon, until there is a serious contender framework for it like Rails or Django, PHP will continue its route to extinction.

I'm not sure if you're serious, but there are plenty of frameworks on a par with Rails at least (nb: I have zero experience with Django).

At the enterprise level, there's Symfony or Zend:

http://symfony.com/

http://www.zend.com/

If Rails is your thing, CakePHP shares some concepts (although I'll be the first to admit CakePHP has many flaws):

http://cakephp.org/

Want something lightweight that's easy to jump into? CodeIgniter's the one for you!

http://codeigniter.com/

And finally, my favourite, Kohana. Absolutely infuriating since they essentially stopped writing documentation for new versions, but if I need to get something written quickly and reliably, this is my go-to call:

http://kohanaframework.org/

There are tonnes of "serious" frameworks for PHP (I've certainly missed out a few), and frankly, if you're going to try to attack PHP, this is the wrong angle from which to do so.

Please don't recommend CodeIgniter. I'm not normally one for swathing "x is bad" judgements, but CI is simply not in the same league as the other frameworks you mentioned.
Tell us why! With the low memory overhead, built-in cache, Active Record (+PDO support) and easy-to-understand MVC approach, I think it is the best framework for writing small to medium-sized web applications.

CI is not Zend, but nothing prevents you from using the Zend libraries with a small CI Library wrapper - I have done so many times in the past, and it works great.

CI gives you very little, and what it gives you is mostly categorically broken. The total lack of post-redirect-get and insane choices on the session data front meant I was using a custom session storage library I wrote instead of the bundled one.

We had issues where the router and loader were not playing nicely at all - we were using the 404 override option in order to do some custom routing (as the router was not flexible enough for even a very basic CMS). However because of how messy the routing code is, and how much of a hack the 404 override was (last time I checked there were several open bugs regarding this on their tracker, some over a year old and completely untouched), it completely blitzed the loaded libraries, so we had to add in more hacks to dodgily clear the cache of loaded libraries and re-run the loader in order to have them available. The only other way to do this would have been to modify the core loader to fix the bug there (but we didn't want to modify core code to make it easier to keep up to date with framework changes), or completely rewrite the router (which really needs to be done, it's a mess).

The database abstraction code is very kludgy and basically useless for anything beyond utterly, utterly basic use cases (there's a reason it's low overhead - it's low everything, including functionality!)

That's just a few of the things we ran into. By the time we went to production I estimate that out of the maybe 30% of CodeIgniter we were actually using for our project, I had re-implemented as custom libraries maybe a third of that amount just to get some sane behaviour, and work around long-standing bugs. Overall I got the feeling that the framework had no solid direction, some of the core components (most critically the loader and router) were quite obviously piles of hacks rather than having been designed and engineered, and honestly the framework was not really much more re-usable or robust than our own custom in-house one. I know it's a very common developer hubris to think you could write your own framework and do a better job, but in the case of CodeIgniter I can confidently make that claim.

On the more technical and abstract side, it's insane that it doesn't use standard PSR loading (so any other library you want to use you have to write a custom wrapper), and the guidance on making re-usable libraries / modules / packages (I can't even remember the right terminology, they use these words in strange ways) is... unclear at best. It uses globals, it's tightly coupled, everything a decent framework should categorically not be. Overall I would say that the level of technical ability on people using and contributing to CI is very low, and most people I've spoken to that think it's great haven't actually used any other framework (which is, frankly, endemic of a large portion of the PHP-using world)

Edit: Also if you care about overhead, you're not writing what I would call a small to medium sized application! Any framework out there worth its salt (and many that are not) will be able to run your application just fine, it's extremely unlikely that the PHP layer will be the bottleneck unless you're writing really terrible code or using a really terrible framework.

Please don't recommend CodeIgniter. I'm not normally one for swathing "x is bad" judgements, but CI is simply not in the same league as the other frameworks you mentioned.

I wouldn't have a few years ago, but the current version seems decent enough. Out of interest, what're your main complaints with it?

I'm not a huge fan of CI, but would prefer it to my personal bugbear, CakePHP.

Having taken over a project that uses CI at it's core, I've found a number of things that definitely put it in a league below frameworks that were built with PHP 5.3 in mind. * Way too much magic - everything (libraries, models, etc.) is globbed onto a superglobal class, which breaks auto-complete in IDEs and in general makes debugging harder * No proper autoloader (PSR-0 style) - the built in autoloader can't autoload anything that doesn't fit into the CI world which tends to lead to unnecessarily large classes (anything that isn't a model gets lumped into a library) * Setting up routes gets messy fast (it's all defined as a single associative array) * No built in template system (which, in my experience, encourages bad behavior in views)
Okay, so a bunch of personal preferences that don't actually matter in the real world? Thanks for your insight, but it does not make CodeIgniter bad.

> frameworks that were built with PHP 5.3 in mind.

Well no crap, CodeIgniter is built for newbies in mind, people who don't have up to date PHP installs because their shared hosting doesn't keep it THAT up to date.

The newest versions of CodeIgniter are VERY good, and just like the haters of PHP, you're just hating on versions of CodeIgniter that are at least 3 versions old. Learn the updated system, then base your claims on that, not something you looked at 2+ years ago.

Those aren't (all) personal preferences. Using superglobals is definitively bad, in the same way that using GOTO is. Not using PSR-0 autoloading is flying in the face of the community consensus and makes it much harder to use other libraries with CI compared to other frameworks.

Your point about PHP versions isn't very valid. 5.3 is over 3 years old now! Plenty of cheap hosts are far more up to date than that.

There is a difference between being "newbie friendly" (which I will admit, CI is - it's a lot easier to get into than say, Zend, by orders of magnitude) and "enabling bad practices". You could say that using mysqli and concatenating data into your queries is newbie friendly, and it is - it's a lot simpler conceptually than prepared statements, but that doesn't stop it being categorically a bad idea.

For the record my CI experience ended about 9 months ago, and I have contributed code to CI, so I feel that when I say certain parts of the internals are very badly coded I do have some valid perspective on that issue.

There's also Slim: http://www.slimframework.com/ ...which you could equate to something like Python's Flask (I think... I only have limited experience with Flask).
We used Slim to build a RESTful API for our product. It was a great experience. Really lightweight, yet the perfect amount of structure to make an easily extensible API.
I've been using Cake since around 1.1 and it started with a decent base but was not very consistent. I just recently upgraded to 2.2 and I was extremely surprised with the amount of refactor and polish in order to make it a very consistent and powerful framework. It's really top notch nowadays. The performance is also better (used to have to do some "hacks" to get good performance before) but I'm not sure how it compares to others.
To be fair, the biggest problem I have with Cake is its ORM; it just feels unnatural to me. You ask for some data, and get back an associative array of values, which you can't do anything with but pass elsewhere. It just lacks a certain sense of OOPiness for me :)
I feel the same way, and I've been trying to get away from Cake for a while, but the fact that everything except the quirkiness of the ORM is so nice that I stick with it.

Also, the next version is supposed to redo the ORM to return actual models.

I wonder if the performance will be better or worst though. Creating tons of objects might impact it but they might be able to do more lazy loading to help.
I've found that Laravel is quite a bit nicer than most other frameworks in PHP. It uses some stuff from Symfony as well. I don't think it's contending with Django quite yet, but it's extremely nice to use and work with. I honestly don't feel like I'm writing PHP when using it.

http://laravel.com

The beauty of PHP is that it is simple to learn and easy to setup. That is why it is popular and will continue to be. Additions, such as the easy-to-use password encryption, are brilliant because it will make it even easier to move from adding some dynamic functionality to building a full app.
Disclaimer: I am working for a shop with much PHP knowledge. There are some really nice frameworks for PHP - for example we are using Yii (http://www.yiiframework.com/), Symfony (http://www.symfony-project.org/) and Flow3 (http://flow3.typo3.org/). I was using Yii in one of my projects and it worked really nice (altough I can't compare it to Rails or Django, because I have no experience with those).
Can you tell us more about your experiences with FLOW3? I work a TYPO3-shop, but hadn't had the chance to use neither ExtBase or FLOW3 much, but it looks exciting, at least after some superficial glances.
This is also the year of the Linux Desktop.
Dinosaurs dominated the ecosystem for 135 millions of years out of last 200, and it took a major extinction event - most probably of extra-terrestial origin - which wiped about half of the existing species off the face of the planet to do them away.

I think you meant the comparison as insulting, but it actually isn't. You're saying PHP is a T-Rex of web development. It's a nice compliment :)

PHP frameworks are pretty decent, and widely liked (if not loved). Though for some reason this doesn't apply to PHP applications: plenty of people dislike Drupal, or WordPress, or Magento. I'm not sure if there's an equivalent situation across languages--does Ruby or Python have loved frameworks and libraries, but unloved (though widely-used) applications?
Wordpress (as stated earlier) is a gong show. I do think people use Wordpress in far too many use cases where other solutions would work better. If you're a designer type with limited code knowledge, or an IT goon who can't really code but can script, Wordpress is often a good fit. But any experienced software developer is going to take one look at the internals and immediately close the editor. I do hear it's getting better, but it's been a while since I last looked at it.

Drupal is an odd duck - it's a framework with a built in CMS. It's immensely powerful for many developers who put the time in to learn it, but the experience is often jarring for traditional "object oriented" developers so they come away with a bad taste in their mouth: "no objects? this is icky!"

Of all the major PHP projects, Drupal seems to be the one embracing good software architecture - Drupal 8 looks to be amazing. It's come a long way from the days of Drupal 5.

Drupal 8 looks very promising with its adoption of Symfony Elements (HttpFoundation, HttpKernel, Routing, ClassLoader, EventDispatcher, DependencyInjection). Presumably it will be easy to integrate with other Symfony stuff and Symfony itself will benefit from the huge Drupal community.
Plenty of people dislike Drupal, or WordPress, or Magento

I can't speak for Drupal or Magento, but WordPress's codebase is a world of pain. I've written a few plugins in the past, and the WordPress code is simply hell to work with.

Drupal is ok, but a bit old-fashioned and quirky. It's highly callback/hook based, which is fine, but it doesn't always have hooks where you need them, in which case it gets pretty ugly.

Magento is on a whole other level of suck. I worked on a highly customized Magento site 3 years ago, and it was the worst experience of my professional career - lousy software and client-from-hades.

The Magento folder structure is just completely insane...some of the templates are like 8 or 9 subfolders deep, and it's the huge mashed up pile of Zend Framework and homegrown MVC, none of which is well documented (Since after all, they want to push you to paid support...)

Oh, and to further cement the suck, the main database tables are in EAV form. Tons of fun to be had.

billpatrianakos: FYI, it appears you've been hellbanned, presumably from the last PHP megathread (judging by your comment history and when they started going dead). Might want to contact pg about it.
There are many that come to mind CodeIgniter, CakePHP, Kohana, etc... are pretty damn good.