I was engaged in a lively discussion on Twitter this morning sparked by someone grumbling that people should not be writing frameworks that target PHP 4. In the course of that discussion, I offered my opinion on a couple of things:
- My least favourite framework suffers from having code that detects whether or not you are using PHP 4
- PHP 5 has been out long enough that pandering (I do not know if there is a better word for that) to the crowd that does not want to update to it is counter-productive.
It was pointed out to me that CodeIgniter has 23 lines of code in it dedicated to detecting what version of PHP you are running. In my opinion, that is 23 too many.
Of course, it isn’t as simple as that. If you have customers who are paying you for your application and they are running PHP 4, well, you have a tough decision: keep supporting them and your application becomes more and more convoluted as the language changes or be bold and tell them “from this point forward new versions of my application will be PHP 5 only.” I think the truth is that very few people are willing to make that sort of stand, and that’s okay. In the end, you really should use whatever tools you are comfortable with. But it’s important to understand why those tools are, in the big picture, substandard.
My personal opinion is that PHP 5 has enough new features that either replace existing functionality in PHP 4 or give you features that were not available before, only sheer apathy prevents you from creating a PHP 5-specific version of your application. Not to mention that PHP 5 itself runs faster than PHP 4. If you have to turn on E_STRICT so your application stops spitting out errors all over the place, you are doing it wrong.
What I think would be very interesting is to see how Ruby on Rails and Django handle this problem: what sort of contortions do they go through when Ruby and Python (respectively) make changes and perhaps break backwards compatibility. Is PHP the only programming language for the web where the people running older versions hold onto it kicking and screaming, despite gobs of evidence that newer stable versions of the language have fixed bugs, perform better, and offer new useful features? Enquiring minds want to know!


Q: Is PHP the only programming language for the web where the people running older versions hold onto it kicking and screaming, despite gobs of evidence that newer stable versions of the language have fixed bugs, perform better, and offer new useful features?
A: Yes.
PHP suffers from its own popularity. It’s as simple as that. Many people find, are given, or are suggested web-apps that were built with a specific version – these people are not necessarily 100% computer literate and when something breaks, they blame their hosting provider. Hosting providers don’t want to deal with the outcry from it, and therefore hold on to the older versions of PHP as long as they can, while still offering newer versions (if their server’s setup properly) to those that opt-in. PHPRC and strives in the newer PHP versions for user-specific ini settings should alleviate a lot of that in the future.
Before PHP became popular, the same problem existed with Perl. …and, sorry, you were asking how Ruby (RoR) and Python (Django) handle that and I really have no idea.
Say now!!! Codeignitor, your least favorite framework, suffers from the same issues that a framework you once wrote a lot about: Cakephp. I’m an avid baker, but I do think its too late to just now be working on a php5 only version. And that version surely won’t be out this year. Anyways, the point of my post was: why only pick on CI? Why not Cake as well?
@Adam
I pick on CodeIgniter because I use it every day at work. Familiarity breeds contempt, and all that.
You’re absolutely right about CakePHP too. CakePHP probably has even more code in it that checks for PHP 4, and that is the main reason why I could not recommend that we use it for future projects at work.
Zend Framework started all this off by insisting that it be PHP 5+ only, and now that Symfony has decided that the next major release will be PHP 5.3 only, I think the time has come to embrace the idea that the amount of work required to preserve backwards compatibility with PHP 4 is a waste of time given how long PHP 5 has been available.