Tech Blog :: Drupal as an Application Framework: Unofficially competing in the BostonPHP Framework Bakeoff

Feb 23 '11 11:20am

Drupal as an Application Framework: Unofficially competing in the BostonPHP Framework Bakeoff

BostonPHP hosted a PHP Framework Bake-Off last night, a competition among four application frameworks: CakePHP, Symfony, Zend, and CodeIgniter. A developer coding in each framework was given 30 minutes to build a simple job-posting app (wireframes publicized the day before) in front of a live audience.

I asked the organizer if I could enter the competition representing Drupal. He replied that Drupal was a Content Management System, not a framework, so it should compete against Wordpress and Joomla, not the above four. My opinion on the matter was and remains as follows:

  1. The differences between frameworks and robust CMSs are not well defined, and Drupal straddles the line between them.
  2. The test of whether a toolkit is a framework is whether the following question yields an affirmative answer: “Can I use this toolkit to build a given application?” Here Drupal clearly does, and for apps far more advanced that this one.
  3. The exclusion reflects a kind of coder-purist snobbery ("it's not a framework if you build any of it in a UI") and lack of knowledge about Drupal's underlying code framework.
  4. In a fair fight, Drupal would either beat Wordpress hands-down building a complex app (because its APIs are far more robust) or fail to show its true colors with a simple blog-style site that better suits WP.

Needless to say, I wasn't organizing the event, so Drupal was not included.

So I entered Drupal into the competition anyway. While the first developer (using CakePHP) coded for 30 minutes on the big screen, I built the app in my chair from the back of the auditorium, starting with a clean Drupal 6 installation, recording my screen. Below is that recording, with narration added afterwards. (Glance at the app wireframes first to understand the task.)

Worth noting:

  • I used Drupal 6 because I know it best; if this were a production app, I would be using the newly released Drupal 7.
  • I start, as you can see, with an empty directory on a Linux server and an Apache virtualhost already defined.
  • I build a small custom module at the end just to show that code is obviously involved at anything beyond the basic level, but most of the setup is done in the UI.

One irony of the framework-vs-CMS argument is that what makes these frameworks appealing is precisely the automated helpers - be it scaffolding in Symfony, baking in CakePHP, raking in Rails, etc - that all reduce the need for wheel-reinventing manual coding. After the tools do their thing, the frameworks require code, and Drupal requires (at the basic level) visual component building (followed, of course, by code as the app gets more custom/complex). Why is one approach more "framework"-y or app-y than the other? If I build a complex app in Drupal, and my time spent writing custom code outweighs the UI work (as it usually does), does that change the nature of the framework?

Where the CMS nature of Drupal hits a wall in my view is in building apps that aren't compatible with Drupal's basic assumptions. It assumes the basic unit - a piece of "content" called a "node" - should have a title, body, author, and date, for example. If that most basic schema doesn't fit what you're trying to build, then you probably don't want to use Drupal. But for many apps, it fits well enough, so Drupal deserves a spot on the list of application frameworks, to be weighed for its pros and cons on each project just like the rest.

Awesome! I saw that backeoff and wanted to do the same thing, but you had the guts (and timing and ability) and did it.

Note of course that Drupal 7 entities move Drupal a good bit further towards assuming less about what you ultimately want to do, as far as things that are less content-like.

Nice work, thank you!

I was asked if the app is still online. It is! PHP Framework Bakeoff Challenge with Drupal.

Fantastic demonstration of Drupal's capabilities.

Just reinforces my idea to use Drupal again for my next web site project.

I am glad I am doing my project as a retired and unpaid volunteer. I'd hate to have to complete with you in the real job market.

I could do what you did in this 38 minute video, but it would probably take me a week (or more).

Thanks for posting this video and app! I was the CakePHP presenter. I think it would be great to have a Q&A session at BostnPHP about which route to go for a project - Drupal / Wordpress / one of the frameworks presented - or something else entirely. Just knowing which questions to ask can help someone with a new project get off on the right track.

Anyway, one of these days I'll get around to learning and building a site in Drupal!

It'd be great to see the final product of the other entries to compare.

Hey dalin - We are making them available through GitHub - I only have 2 up so far (Cake and Zend), but will get the rest up and with more documentation soon.
Check them out here:

Excellent post. I had a similar rant, although not as well thought out or with as much detail :)

I ran in to having node titles be required on what really was a site driven by a CMS, but I did not know the node title because I was planning on deriving it from CCK fields. I figured out pretty quick "crap, I need to fill it in with some filler and hide it so the form will submit" - which would have been a TERRIBLE solution. Then I was turned on to - I mean, of course there is a module for that.

Works absolutely perfect. I couldn't have coded a better solution myself.

I have targeted non-traditional non-CMS type things for Drupal as well. Just using it as a framework, more or less, however, I do get concerned with unnecessary overhead of the node structure, and adding additional fields through CCK isn't as cleancut as a straight table being designed and such. However, the way CCK (and Fields) functions works so well, keeps enumerated values in check, has all the built-in validation and such, I don't usually mind that much :)

Nice, I didn't know about Auto Node Title, I should have used that on this app!

Great little demo. Reminds me of the seminal "Blog in 15 minutes" the Rails people used to hawk.

And you're right, of course, especially since Drupal is gaining more and more command-line abilities on a daily basis. With Drush and related utilities, a lot of these "framework"'y aspects are rapidly becoming part of the stable diet of any Drupal developer.

Having both web- and cli-based configuration tools certainly beats having only one or the other.

Hi, Ben -- great idea! I submitted this story to Slashdot, at . Fingers crossed....

It was picked up!

Good luck with the Slashdotting....

I think I heard clapping at the end... or was that just me? Well done.

That was clapping for the CakePHP guy, who started and ended at the same time I did. I left the background audio on (with the volume lowered) so that people who were there can verify I was in fact sitting in the room.

I'm all for code snobbery when it comes to evaluating frameworks. Especially if it means I can avoid the terrible code that is called Drupal.


Wikipedia seems to backup your claim that Drupal is a framework as I read it. The following lines are from it's site defining application framework.

In computer programming, an application framework or application development framework consists of a software framework used by software developers to implement the standard structure of an application for a specific development environment (such as an operating system or a web application).

Application frameworks became popular with the rise of graphical user interfaces (GUIs), since these tended to promote a standard structure for applications. Programmers find it much simpler to create automatic GUI creation tools when using a standard framework, since this defines the underlying code structure of the application in advance. Developers usually use object-oriented programming techniques to implement frameworks such that the unique parts of an application can simply inherit from pre-existing classes in the framework

Nice one. Sadly, still finding loads of bugs and issues with Drupal 7, but we'll get there.

Interesting discussion on framework vs CMS.

I enjoyed the video. It would be interesting to do the same thing with Drupal 7 and see what efficiencies may be found, if any.

Upload the video to Youtube, Vimeo is telling me to install Safari(!). FCOL.

To the author, I feel like you've got a really valid point to make about what defines an app compared to a framework; but I did notice something very particular about why I feel Drupal is not necessarily a framework. While my complaint isn't that the UI is used to define model attributes, per ce, but more that Drupal isn't a "constructed" user experience. Coming from Ruby(Rails), personally, I feel that there is a distinct automagic missing from the way Drupal creates an application from it's code. Maybe it's simply less efficient than a traditional framework? But it seems to me that, traditionally, submitting code through an interface is counter-productive to a file based coding route. I'm probably getting a bit confusing and vague considering I lack the vocabulary to communicate exactly how I'm feeling here; but if a framework requires you to use an application to communicate back to it(even if this is the "Drupal way") it is selling itself short from what a framework *should* be.

It's not just rake tasks that qualify Rails as a framework, and while Drupal has many similarities with what we traditionally seek in framework, I would never expect a framework to take me into an application to develop code. Maybe Drupal's interface is a kin to RubyMine, maybe a built in IDE makes Drupal an even *better* framework than other legacy solutions. Though, I feel like the level of control diminishes for a developer, or the sort of speed and agility you expected to have over every attribute of your code and data, is also diminished. These are simply irksome observations, and none of it based on experience however. While Drupal is quacking like a framework, it doesn't look or walk like a framework -- though I could expect to see a shift in opinion about this.

Very good points. Drupal has a Schema API which you can use to build a totally code-based schema like in Rails. But generally that's used for supplements to the core "node" system; if you're not using nodes at all, you're probably better off using another framework. Re: diminishing "speed and agility you expected to have over every attribute of your code and data" - that's a tricky one. I'd agree overall, but I'd have to see what that means in practice for specific use cases. My experience has been that Drupal isn't necessarily slower to develop for; but where it can lack is in the haphazard way code can be structured because of its procedural (non-OO) hook architecture. A developer can see something happening in the front end and have no idea where in the system is the code or setting causing that effect; I suspect in Rails or similar that doesn't happen as much.

Very cool. I do mostly back end Drupal development and can attest to its robustness through the awesome hooks and api. I pull up all my sites in NetBeans and can bang out code all day without having to touch the gui. I can be a bit of a code snob myself but IMHO Drupal is as much of a framework as others AND has the added benefit of being a full-fledged CMS. It's a great utility.

Who won?!

I don't think there was actually a winner... the presentation styles were all very different so it would be apples and oranges.

I feel like this is a bad Jeff Foxworthy joke.

Q: How can you tell when software is a CMS and not a framework?
A: When it has CMS in the title its a CMS.

It's obvious that you love Drupal but if it is a framework than so is Excel, Wordpress, Mediawiki, Jira, Joomla, Trax, PhpBB and every other piece of software that allows you to extend it via plugins. Could I hammer on any of these long enough to make them do X, Y or Z? Absolutely. Is it a good idea to write a spreadsheet in Jira or a web site in Excel? Absolutely not. Please stop trying to bend reality to your point of view. You are wrong. Just admit it and move on. If it were a CMS bake off I wouldn't want to watch some jackass build a CMS in Zend Framework so show the same courtesy.

Apparently, "hammering" for 30 minutes was long enough.

I would argue that a framework is a system that is flexible enough that it allows one to build many different things with its basic structure. ..but that's just me.

Would the organizer have accepted a response that claimed Drupal was a framework bundled with an example CMS app?

A fine presentation of Drupal's stregths. Two questions/requests: a) Is there a higher resolution version avaialbe; b) Is the drupal installation for this demo available in source form with or without he db?

a) You should be able to download the source video from Vimeo, which might be higher res.
b) I would have to put the components into Features to make it exportable in code, and I don't have time to do that now. You're welcome to follow the video and re-create it, of course.

I'm using Drupal as a framework for building content management applications. I totally agree that Drupal straddles the line between a CMS and a 'framework', but I think it depends on what you're using it for. I suggest that maybe the CMS definition has to do with providing a UI to access data and the framework has more to do with providing new exciting functionality that pushes Drupal outside of its traditional usage.

For example, I have a base install in which I tie together ~40 modules (Drupal 6 version) and configure them automatically either using the features module or in my own code. This could all be done using the UIs provided by core and various modules and it provides some basic functionality. I think that here I'm really using Drupal as a CMS because I'm not really creating something new, but creating a 'version' of Drupal. This part really just does what Drupal is good at...managing content. It also provides the UI for my more unique functionality.

However, next I'm developing a complex inventory 'feature' that interacts with core and several modules and also provides a-lot of new functionality. It really stretches what Drupal is traditionally used for. Here I think I'm using Drupal as a framework to provide a unique application.

Just my opinions...ignore as you like!
Ted - Saybit

I think that perfectly demonstrates the point. So the question is, take the scenario you described vs one where someone uses a framework tool to build a schema (content types), admin backend (I know at least Django does this semi-automatically), etc., and then builds it out further in code. Does the initial buildout stage in the framework differ fundamentally from that in Drupal? Drupal's is done in a UI and the frameworks are done through a shell and a little code. I submit that what makes a framework a framework is how robustly you can build out your app *after* the initial buildout, so Drupal clearly fits the bill.

Any chance of a high-res version of the video?

Try downloading the source video file from Vimeo.

Fantastic demonstration of Drupal's capabilities.

Thanks For shariing innovative information.Keep writing more information.

Hey I just came across your blog today. This post stuck me here around.

I have been part of a big echo system like web application development which includes work flow management, payments, dashboards, 12 multi-site installations and lot more. The base we used is Drupal. So just like you did we used Drupal as framework and built our system around it.

I very much agree with my own development experience in Drupal that it can be used as a framework. It's just a matter of thinking.

Drupal was not intended to be an "Application Framework" since its conception, Drupal is a very flexible and powerfull CMS, but it do not brings the posibilities to organize and reuse software-components like others Application Frameworks does (Yii, CodeIgniter, Cake, etc.), that is, it do not natively promotes patterns: MVC, O. O., etc.

In short, Drupal is neither a Silver Bullet... It would be something like trying to use Yii as an CMS...

Roger, I'm not sure what you mean by "possibilities to organize and reuse software-components like other Application Frameworks," but wouldn't the myriad of reusable/portable modules on constitute re-usable software components?

IMHO the Drupal model is a future of the frameworks. I think that common Frameworks like Cakephp, ZendF, Codeigniter, Simphony, etc. will implement GUI mode/layer.