Bye Bye PHP 5.2

Posted: 2012-10-11
Category: PHP

PHP is undeniably the most used language when it comes to building web applications. Around 78% of the internet is powered by PHP and the most popular web applications and content management systems are all still PHP.

The reason these applications do well is because PHP hosting has been widely available for over a decade. Because PHP is on 90% of hosting setups from dedicated systems to cheap $4 a month deals, application developers have targeted PHP to help them reach their highest audience. This makes the hosting companies keep their interest in PHP and its a circular effect that keeps it at the top - even if it's not the shiniest language in the world.

Sadly, PHP hosts have always been slow to upgrade, which can be attributed to a wide variety of (occasionally fictional) reasons. PHP 5.3 was the worst, with huge companies like Rackspace taking three years to even make PHP 5.3 available as an option on their "Cloud Site" product.

Who cares?

The prominence of specific versions of PHP effects all developers on a scale from "not at all" to "an infuriating amount". If you work for a company that manages their own servers (be it physical or virtual) then you don't need to care. I expect you upgraded to PHP 5.3 within a few months of release and you're probably rocking PHP 5.4 already or at least have a testing server set up to see how your code works.

That is great for you, but distributed application developers are stuck working for the lowest reasonable common denominator. That means every project has to look at their target audience, crunch usage stats and work out where they draw the line. For example, PyroCMS had 23% of its users running PHP 5.2 only 3 months ago. Now I've seen that drop to 15% and with MediaTemple and Rackspace Cloud Sites making the jump to PHP 5.3 I can safely say something now that I've wanted to say for years:

FAREFUCKINGWELL PHP 5.2!

My personal and professional projects have all been up on Pagoda Box (for better or worse) where 5.3 is an option or EC2 where PHP 5.4 or dev builds of PHP 5.5-dev work just fine if i'm feeling fancy.

The only time PHP 5.2 has ever become a factor for me is working with PyroCMS and occasionally PancakeApp.

Why the noise about a 0.x move?

PHP 5.3 is not a trivial update. If you guys remember, what became PHP 5.3 was originally intended to be PHP 6.0. The dev team hit troubles working out the Unicode support and basically every other feature (Namespaces, anonymous functions, late static bindings, etc) got back-ported and PHP 5.3 was born. It's thanks to these features that Composer has taken off massively and with PSR-0/1/2 we're seeing PHP grow up out of its ugly little teenager stage into something considerably more mature.

Well tested, reusable, framework agnostic packages are being built which can be used to build much more stable applications. It's thanks to this that I can move PyroCMS over to PHP 5.3 and really not be concerned.

  • PyroCMS 2.2 will be out within a few weeks still on PHP 5.2 (no point changing things at the last minute).
  • PyroCMS 2.3 will be using a number of PSR components to clean up the existing code-base (for example, replacing some messy models with Eloquent ORM)
  • PyroCMS 3.0 will be a rewrite, entirely PHP 5.3 using components from Laravel 4.0, a few from FuelPHP 2.0 and a few third party components.

Thanks to most of them supporting at least PSR-1 (where people have complained that camelCase is enforced) all of these components will look and play exactly the same on the outside, so PyroCMS won't be stuck with some under_score and some camelCase methods. See, this PHP-FIG/PSR stuff is well thought out after-all.

It's a tough road but it will be possible to walk it without breaking everything. By January 2013 PyroCMS will be PHP 5.3 without losing market share, and the awesome tools being rolled into the core will only improve our uptake as developers rush to play with amazing tools like Monolog, Eloquent, Events and QuickCache.

PHP 5.3 Hosts

I hate it when people try to wrap their own opinions off as fact, so there are plenty of you that will still need to think about whether or not your applications can make the move, and of course you need to weigh up why too - but with so many standard hosting companies offering PHP 5.3 it currently seems silly not to:

More here

All of the hosting companies adopted this at different rates, with Rackspace Cloud and Media Temple only playing catchup in the last month or two. Crucial very proudly told me on Twitter they've been supporting PHP 5.3 since July 2011 (2 years after it came out) but they seem on the ball now, and have been supporting PHP 5.4 "since it came out".

Immediate (but not rushed) or even speedy adoption is all we can ask for. Being stuck with a 4 year lag between release and real-world usage kills me every time.

Wait, cheap PHP 5.4 hosting too?!

There are a few places to get simple PHP 5.4 applications running but not many at this point:

I don't know of any more, and yes I realise Orchestra is a PaaS and not a standard hosting company, but there are not many PHP 5.4 hosts around so figured I should mention them. Pagoda Box have also been talking about getting PHP 5.4 in and Rackspace are not TOO far from it.

It'll be another 2 or 3 years before developers can use traits and other cool PHP 5.4 features in distributed applications, but moving to PHP 5.3 is more than enough to totally refresh my love of PHP.

Get in touch

If you represent a hosting company that offers PHP 5.3 or PHP 5.4 hosting let me know on Twitter or in the comments and I'll update these lists above. Anything I can do to get people off PHP 5.2 literally makes my life better. I'll be starting the PyroCMS 2.3/develop branch in a week or so then I never have to care about PHP 5.3 again.

If you're stuck with PHP 5.2, let me know as to why in the comments. For example, I know there are lots of ExpressionEngine users are trapped in 1.6.x and unable to upgrade. EE 1.6.x does badly on PHP 5.3 and upgrading to EE 2.0 is a mammoth task, but they have to upgrade the software at some point - or at least use PHP 5.3 for new projects.

I'd also be really interested to hear from other open-source and distributed app developers, to hear how they're managing the move.

Comments

Gravatar
Tim Post

2012-10-11

Any web host running C-Panel/WHM can *easily* upgrade to 5.4, and even automatically add a patch to squelch deprecation warnings due to rampant (ab)use of the pass by operator. There is no reason for 90% of all shared web hosts to be running *anything* less than 5.3, you can build it in just a few clicks.

Most companies would have very few support incidents if they upgraded to 5.4, provided that they did it carefully.

Gravatar
Benjamin Kohl

2012-10-11

HawkHost is a great host. I've had nothing but pleasant experiences with them and bumping my sites up to use PHP 5.4 was painless. For personal projects, I like being able to use the latest and greatest releases of software.

Gravatar
Victor Michnowicz

2012-10-11

WebFaction has PHP 5.4 http://blog.webfaction.com/2012/03/php-5-4-is-here/

Gravatar
Christian D.

2012-10-11

Phil,

Your comment on PyroCMS 3.0. Does this mean that Pyro will not be codeIgniter based in the future? As bad as it sounds I try and stay out of the higher level programming shit that you and others love and just solve problems and solve them quickly for the people that I do work for which is why I think PHP succeeds so well (yes it does allow people to write crappy code I realize...)

Thanks,

Gravatar
Ramiro

2012-10-11

Hi Phil, Webfaction has PHP4

Gravatar
Boris Strahija

2012-10-11

Webfaction (http://www.webfaction.com/) also supports 5.4. Works great and not to expensive for small sites.

Gravatar
Dele.o

2012-10-11

webfaction.com is worth a mention (5.4)

Gravatar
Rich Lovelock

2012-10-11

Finally coming round to the merits and stability of Laravel? Nice to see.

Gravatar
Gregor Mckelvie

2012-10-11

Good post Phil. Glad to see Vidahost on the list. I've been using them for a while for CI and EE. Support is great.

Gravatar
Nyan Lynn Htut

2012-10-12

Hi Phil,
What is main difference between FuelPHP 2.0 and Laravel 4.0?

Gravatar
Kapil Verma

2012-10-12

You missed out one of the finest shared hosting out there who were the one of the earliest providers of php5.4 hosting ... webfaction http://www.webfaction.com/

Gravatar
Dean Farrell

2012-10-12

We use BlueHost for many of our apps. They offer PHP 5.4 and have solid customer support. You can't beat it four dollars a month.

Enjoy your blog. It's one of my must reads.

Dean

Gravatar
Kate

2012-10-23

Thanks for sharing the great news! It was included into a digest of the hottest and the most interesting PHP news: http://www.zfort.com/blog/php-digest-october-22/

Gravatar
Vladimir B.

2012-10-23

We (Webhostingbuzz) support PHP 5.2 and 5.3 versions on our shared/reseller servers and plannig to include PHP 5.4 too on our new servers.
Please take into account that popular hosting panels have no possibility to use both PHP 5.2 and 5.3 branches at one time. You have to choose one of them. So if you need to use both version - you should figure out how to do it correctly and available for future updates.

Gravatar
Jim

2012-12-19

For many smaller businesses, the move to 5.4 will be painful, when forced.

Even relatively simple applications written in php 5.2 may need tweaks for 5.4, or may require major overhauls. To programming geeks, this may be fun, but to a small business, it means $$ out the door - for 0% increase in functionality. Shopping carts, blogs, custom applications - even if they are working well, will break when hosts stop supporting 5.2 and force the move to 5.4.

Great job guys - who needs backwards compatibility anyway? Every web app should be rewritten every 2 years, right?

-Jim

Gravatar

2012-12-29

Jim: You seem to be arguing against a point that was never made. Nobody is saying you are forced to upgrade to PHP 5.4 immediately. Where did you get that idea?

When I run a project, I use the latest version of PHP.

When I take over a project, I upgrade it to the latest version of PHP.

If you run a project, do whatever you like. If you have old software, don't upgrade the server.

If you want to keep the same PHP 5.2 code on its own PHP 5.2 server until the apocalypse then carry on. Everybody else will be trying to upgrade as and when it seems logical, which really is the next version of the application or when your design team are two weeks behind a milestone and developers have sod all to do in the meantime.

Chill :)

Posting comments after three months has been disabled.