2009
08.25

So there’s all this hubbub about PHP frameworks, and heated debate over which one is the one true framework to rule them all. And you wondered, “So what is all the fuss about, is there really one framework that solves all of my problems?” I’m not an author of any particular framework, nor do I portray one on television. Let me take an unbiased swing at what I see as the lay of the land regarding frameworks and our favorite little programming language, PHP.

Frameworks were created by developers, for developers – with the main intent to streamine the effort needed to create features and functions that were common across the vast majority of websites that they developed in their day to day work. Login, database access, caching, templating, session management, filtering of user input, the list goes on and on. However there are different approaches to how a framework can be used to your advantage, and the difference can be sometimes subtle.

NOTE: I’ve found another good reference on web frameworks, with a different view.

Now what was I saying? There are really two main kinds of frameworks: stack and glue.

Stack ‘em up, bartender

The concept of stack frameworks – sometimes referred to as scaffolding frameworks – is to generate the majority of the base code needed to produce a full-featured environment for the developer to be as productive as possible. The concept is to provide the full stack, with deep integration and workflow suited specifically to benefit the needs of the developer.

On the one hand, stack frameworks can be wicked fast for prototyping, and you can also take advantage of the stack to quickly add additional features to an existing application. As well, many developers appreciate the completeness of the stack approach as upgrades are easy to perform, and are usually done as one atomic operation.

On the other hand, stack frameworks are also referred to as opinionated software, meaning the framework has a strong opinion about how things are to be done; and if you have a different opinion then you’re not going to get along very well. It is commonly said – and commonly debated – that stack frameworks are more vulnerable to performance and scale issues as they attempt to do too much for too many… And ultimately fail to meet the needs of everyone to great satisfaction.

Notable stack frameworks are Ruby on Rails (the real pioneer in this regard), CakePHP, and Symfony.

Sniffing glue

Glue frameworks are for the do-it-yourselfer – you glue together the parts specifically required by your application, and nothing more. This takes a much more hands-on approach for the developer, and usually means prototyping is not as insanely fast as a stack framework, however prototyping is still very rapid. Most importantly the performance and scaling of glue framework applications usually can be mitigated by extending an existing part of the framework, or replacing it altogether. For this reason a lot of developers prefer glue frameworks, having lived through painful customization efforts on less flexible platforms. Glue frameworks are usually very modular in nature, and that provides the additional benefit of having a large array of additional add-ons that developers can take advantage of.

The main drawback for glue frameworks is that they do require more effort from the developer. If you are light on development resources, or are more worried about the ongoing maintenance of your application once it is up and running, then this can be of significance.

Notable glue frameworks are Zend, Joomla! 1.5, Code Igniter, and KohanaPHP (my current favorite).

But wait, there’s more

Joomla! 1.5 is a CMS“, you say. Technically you’re right. However Joomla! 1.5 is actually two Joomla!’s – the framework, and the CMS. Speaking of CMS, we must include both Joomla! and Drupal here, as IMHO they provide an even bigger benefit to the client – software longevity and maintenance.

As a developer, you usually don’t worry about what happens after launch. For the folks that live and die by this application however, that is of paramount importance. For them, they need to know that their investment is protected from bit rot, or the slow decay of unmaintained software. What exactly does a CMS like Joomla! or Drupal do in this regard?

First, they provide a base platform that in essence is a finished and complete starting point for your application platform. That means you are able to run a basic website out of the box, with minimal or no modification. Additionally, each also boast a rich array of third party goodies that can be added for instant gratification – forums, integration with social media services, photo galleries, you name it.

If you are diligent about your development practices, you should also be packaging up your software as an extension to these environments. This provides the additional benefit of reuse, so software you write once might find a second life for another website or application purpose.

Finally, these are complete environments that are maintained by a group of folks dedicated to furthering that software project. This is living software, or software that takes on a life of its own as a variety of different people contribute to the evolution and maintenance of that software. By basing your website on one of these platforms, your client can take advantage of every update and enhancement this community produces for that software project.

There are a great many frameworks out there that are not covered, and that is merely because I cannot keep track of all of them. What other PHP frameworks deserve mention? Did I miss one that really deserves mad props?

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • SphereIt
  • StumbleUpon
  • Technorati
  • TwitThis
  • Identi.ca
  • Tumblr
  • Twitter

6 comments so far

Add Your Comment
  1. you forgot to mention Yii Framework from the author of Prado Framework.

    http://www.yiiframework.com/

    it looks like Ruby on Rails and has ActiveRecord.

  2. You’re the second person that recommended that framework, I have to check it out.

  3. I tried CakePHP, Symphony, CodeIgniter and finally Yii. I did some simple testing on each of them – creating a single controller and view, but no model because I didn’t want data access to skew my results.

    I created a simple test where the model set a bunch of data and the view displayed the data. I used the template system in each framework. Aside from data access, it illustrated a typical page request lifecycle.

    After running some simple benchmarking using apache bench (ab), it was clear that CakePHP was the slowest of all with an average of around 18 requests/second. I was very surprised to see that, since I hear so many great things about Cake. Yii rolled in at around 120 requests/second. An incredible difference which can be attributed to Yii’s lazyloading technique for all classes. I *think* CakePHP 3 is going to use the same technique for loading modules and classes to help boost its performance.

  4. [...] link is being shared on Twitter right now. @mitchitized, an influential author, said Going to bed now, [...]

  5. Interesting! Always looking for useful SEO tips.

  6. @Brian Migliorisi: CakePHP was designed for older PHP4 and tried to emulate a lot of OO stuff that was not existent in PHP at the time. This obviously comes at a heavy price — we were doing some profiling there and it runs like 250 KB in the memory even before it starts doing anything useful. It is a great framework to bake something really fast, but do not expect it to scale. The original developers of Cake actually started the new project called Lithium (http://lithify.me/), which is a complete rework for PHP 5.3 and higher. It uses the new advanced features now available in PHP and should be much faster and more scalable.

    The newer frameworks, like Yii and Kohana are created for PHP5 and obviously are much optimized (and therefore fast and scalable) as compared to Cake.