
Drupal as an MVC framework?
by Cameron
A couple of years back there was a bit of chatter around the place regarding using Drupal as an MVC framework. I didn't pay much attention to it at the time, but I am finding myself in a situation where I need to develop a very large software project that must integrate with a CMS frontend, and it has led me to exploring a number of different solutions.
As huge Drupal fans, it's a given that we'll build the client's frontend in Drupal - it's a fantastic CMS, and we've settled on it as the platform of choice around here for a huge list of reasons - but it isn't exactly an ideal platform for developing large software packages in. Where Drupal excels is writing code to extend or modify the core CMS, it isn't really designed around the idea of providing the tools that developers use for large, independent projects.
For this project, I think we'll go with Zend, and actually separate the two applications completely. Tightly integrating the two platforms poses some difficult issues in deciding which package is responsible for what and at what point, which just adds a lot of pointless complexity. As an example, say we were to decide on using Drupal's user + session management tools, that's fine, but when a logged in user is posting to a Zend form, well, Zend's MVC has a .htaccess file that takes control of the request in the same way as Drupal does. So which one does it use? You can't frame the Zend form, because then you don't have the Drupal session any longer, and building a few "separate" forms that aren't MVC seems hackish - the point of using an MVC framework is to homogenize the application's structure and make everything clean, every time you are thinking of adding chunks of "exception" code to an application, you should be rethinking your architecture instead.
On the subject of Zend Framework, I am growing to like it more and more. A lot of frameworks, once adopted, force the entire project to write your application in THEIR way. This isn't always a problem, but the Zend philosophy of "use only what you want" loose coupling of components means you aren't tied in, which I've found makes the first few steps in to the framework a lot easier, and it makes the overall learning curve less steep. All in all, the two technologies, Zend and Drupal, have very different areas of expertise, and they should stay that way. If Drupal started taking on dreams of being a full-scale app framework, it'd lose its focus, and I don't think that would have a happy ending for any of us.

As someone who has build applications both with mvc frameworks (symfony) and drupal, I have to say that this was definately the right decision. Drupal in fact is a great cms, but code wise a really unconventional one. If you are used to common file structures, oop and so on you you probably will be lost, even more if more people work on the same project.
Post new comment