Contact Info

(for those who care)

Instant Gratification   

Wed, 02 Jul 2008

Simple PHP Framework Performance Comparison




Baseline HTML


Baseline PHP







Zend Framework




Up at work Rasmus always dogs on PHP frameworks due to their “high per-request overhead at scale”. There was another article I read recently about PHP itself being a web framework more-so than other programming languages. Ah, here it is - the article comparing PHP out of the box to rails.

Sure, Cake, Symfony, CI - they all help you build PHP applications. But unlike a Ruby framework or a Python framework, coding is perfectly tolerable without them. Of course, most developers tend to create their own framework as they go along - I call this PHP’s DIY framework mentality, where you build the last level in your stack, and by extension you know exactly what’s going on under the hood.


The idea being that when you take on a framework, you get a rapid increase in initial development speed, but a lot of decisions have already been made for you, and it might not be convenient to shake out those rough spots after you’re significantly invested in the platform. It is extremely easy to make the case that if you have this problem, it’s a pretty good problem to have.

Personally when working with frameworks, my goal is to have as little framework-dependent code as possible, such that when I do feel the need to switch from framework a to framework b I don’t lose my “logic”. My strategy is generally to have as much code as possible in library classes with unit tests, then layer functionality on top of that in whatever framework du-jour happens to be appropriate.

The other thing Rasmus talks about (which feels funny to most PHP programmers) is that you shouldn’t really program in PHP. He thinks that you should do your serious work in C (making it a PHP extension) and use PHP just for the HTML, etc. When people come up with “I’m looking for a good templating language for PHP”, his general response is: “PHP makes a pretty good templating laguage.” :^)

See the principle of least power for an example of what people asking for a PHP templating language are really asking for. Maybe it’d be nice to add an extension to PHP like:

<?simplephp … ?>

…that only accepted echo, foreach. It’s not about PHP’s fitness for purpose, but that it has grown to be too powerful, and people now tend to use it as the general purpose language, muddying some of the benefits that it started off with.

10:19 CST | category / entries / links
permanent link | comments?

Like what you just read? Subscribe to a syndicated feed of my weblog, brought to you by the wonders of RSS.

Thanks for Visiting!