PHP needs some work

I’ve been developing software for about 20 years. I’ve used many languages in various stages of maturity. Over those twenty years I’ve seen steady progress in languages becoming better designed and easier to use. This benefits the overall software industry and makes my life easier when producing complex applications (simple problems typically don’t require complex tools).

This trend seems to be in question with PHP. I’ve been diving into the deep end of PHP (v5.2+) over the past couple months. My intent was to build, from the ground-up, a usable PHP site. I would focus on the process and over-design the code, no quick-and-dirty hackery (not yet, anyway). Slapping code together to ‘get it to work’ would only cover up the problems that I want to hit head on.

PHP is not new or young. PHP is mature, heading into its third major revision. PHP has no excuses for fundamental design stupidity.

Problem: There is no per-directory PHP configuration.

This is a ginormous omission. Apache has .htaccess, but PHP has … um… yeah, nothing. The guys at PHP tell you to use .htaccess. The problem is most (all?) hosted PHP sites are running PHP as CGI (not module), which doesn’t support .htaccess. This is actually the real-world preferred method of deploying PHP, since it is much more secure. Regardless of why, there are many PHP installs using PHP-CGI, where no clean solution exists for local, per-directory configuration. Only supporting one, global php.ini forces people into hackery land to get stuff done.

This problem really manifests when virtual hosting, where a single apache/php install is to serve many vdomains out of various directories. Assuming the vdomains care about security, PHP is run as CGI (separate user for each vdomain, for example), and thus have no way to have per-domain configuration. The I Can’t Believe I’m Doing This hack is to have separate PHP installs for each domain, each with their own, isolated php.ini — even though 99% of the configuration is identical.

I hope the guys at PHP realize PHP-CGI is being used, and solution for per-directory configuration overrides is needed.