PHP has been incredibly successful as a deployment platform for web applications. The WordPress blog brags that the WordPress 2.0 series has been downloaded 1.2 million times.
However, PHP as a platform is far from homogenous. With many different versions installed and the vast configurability of php.ini, there can be a great deal of variation from PHP installation to PHP installation. PHP developers often ask what should I target? The question is the same if you want to write the next WordPress, or if you want to make sure your code is reusable for the next client that knocks on your door.
Nexen has been publishing PHP version adoption statistics for some time. Damien Seguy has really gone the extra step now by collecting and publishing configuration statistics. These are generated from scanning publicly available phpinfo() output.
The stats range from useful to blog candy.
One thing to keep in mind is sample bias. Damien compared the php version number of the sample against the version data collected from expose php and found they correlate well. But, perhaps there is a bias toward certain configuration settings (or versions) among those who have public phpinfo() data and those who do not. (The stats do have suitable disclaimers.)
Its hard to look at stats like this and decide what they represent. According to the Zend blog, 81% of their customers are using PHP 5, while the nexen monthly numbers report 11%. I think its fair to say that all of Zend’s customers use PHP, while many servers that expose_php are domain parking or serving static pages. What is the adoption rate for php 5? Who knows.
It would be interesting to see the correlation between those installations with expose_php off and the monthly version data, collected from the broader set of servers with expose_php on. I think it would also be interesting to see what functions are being disabled with disable_functions. Which extensions are being loaded? How many servers are running an opcode cache?
Which version of PHP to use? PHP 5 versus PHP 4? Unless you are constrained by legacy PHP 4, the answer is definitely PHP 5. Targeting PHP 4 isn’t going to make you the next WordPress. Its just going to put you as far behind the version adoption curve as they are.
PHP 5 is vastly easier to develop in than PHP 4. Development is expensive. Hosting is cheap. Don’t let the tail wag your dog. If your host doesn’t support 5, change hosts. PHP 5 hosting is not rocket science.
I know the decision is that not simple, but the excuses for remaining with PHP 4 are dwindling.
Which configuration options to target? There was some talk recently on the PHP internals list about creating a recommended .ini profile for development environments and one for production environments. I think this is a great idea. Hopefully, then folks installing PHP can choose a profile instead of setting individual .ini options. Perhaps this would help reign in some variability and reduce some Paradox of choice style unhappiness.