Last we checked, PHP IS a framework.
When it comes to web programming languages, PHP probably holds the record for copping criticism from the community at large. Comparisons with alternatives such as Ruby on Rails and Python/Django are common; defenders of PHP are quick to criticise the comparison of a language and a framework. But at the end of the day, developers work with Ruby on Rails, and with Python/Django, and with PHP. Just PHP. For most of the PHP applications out there, the language is just perfect, because PHP, to an extent, is the framework.
PHP is designed for the web. You could plug vanilla Ruby or Python into a web server and get up and running pretty quickly. But, at least at a basic level, you’d want a framework to deal with common issues of web development. In PHP, you just get started. PHP and Apache work out request data, output handling and more, right out of the box. (PHP also masters deployment.) David Heinemeier Hanson, the creator of the Ruby on Rails framework, calls this the immediacy of PHP.
Now, consider the “average” PHP frameworks. They help you handle request data, manage your output, control app flow – essentially, extending PHP’s inbuilt functionality. They are, therefore, PHP frameworks on the PHP framework. PHP provides a vast array (pardon the pun) of functionality out of the box. But when you want to do things your way, it gets out of the way, and this is really important when building anything beyond a simple database frontend.
How many PHP applications in wide distribution are built on a third-party framework? MediaWiki? No framework here. WordPress? Not here either. Drupal? You get the idea. Each of these applications have their own framework, inasfar that the developers built a structure for their code that suited what they were trying to create. These three, and the countless others, clearly did something right – MediaWiki even powers one of the world’s top 10 websites. And when building these “frameworks”, PHP helped them along the way.
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.
This comes back to the oft-cited “best tool for the job” argument – but by being a “half framework” of sorts, PHP simply helps you within a web context. I’m sure Rails is great for countless applications; Ruby syntax helps a little too. But beyond the basics, the language becomes increasingly irrelevant, and a framework will force you to build your app according to design decisions made by the original developers. On the other hand, PHP allows you to quickly put together your application the way you want, helping you with the web-based aspect, and without having to break the language/framework to achieve your goals. Essentially, PHP is the web layer without the framework baggage.
Twitter recently had some downtime that could be attributed to its use of Ruby on Rails. Now, there’s nothing wrong with Ruby, or Rails. But Twitter is a messaging system, RoR is an application framework. Could Rails be worked around to suit Twitter? Maybe. Could Twitter have avoided these problems if they’d used PHP? Probably. Twitter’s developers have noted they weren’t quite expecting the site to be so succesful. If they had built it in PHP, they would probably have encountered other (similar) problems earlier on, rewritten the entire app while it was still feasible, and built a powerful system that could scale just fine (likely with the messaging platform in C). Using PHP could have helped, not as a language with syntax and libraries as such, but as a web development platform that gives developers the freedom to architect their systems as they want. (They could also have tried Erlang.)
So the next time you’re on the lookout for a PHP framework to build your killer app on, consider using the best framework of them all: PHP. It will give you the freedom to achieve what you want, how you want, with results. A quick hack? Check the manual, it could be a one-liner. A massive distributed messaging platform? Full steam ahead, build it your way. For everything in between, there’s a multitude of options, but if you have the time, PHP is all the framework you need.