This post is in reply to a comment on a previous article that I thought contained some good questions:

Hi Josh,

Saw your post on the cakePHP list regarding Drake, here http://groups.google.com/group/cake-php/browse_thread/thread/4d0ad8b73a5... .

I'm hoping you won't mind answering a couple of questions.

In particular, I am concerned with the performance hit of running a framework within a framework, and all the associated redundancies. Was performance something you looked at in any detail?

How much harder is it to work with Drupal's API from within cake than it is to write a native drupal module?

Did you feel the benefits of using cake overcame the increased complexity of having to bridge using drake?

In your opinion, if one wanted to develop a (reasonably complex) module for drupal, would you recommend writing a native drupal module, or writing a cake app and bridging it with Drupal?

Thanks very much.

Hopefully you will be kind enough to reply.

Sorry for taking some time to get back to you! Been busy!!

Yes, I looked at performance issues with Cake in Drupal (Framework in a Framework as you said). For our application, we're weren't looking at really high traffic. The initial box I had for the project was an old dual P-III system running RHEL5. It performed pretty well with some unexplained pauses here and there (may have been hardware related).

We recently migrated the site to a Virtual Machine hosted on a VMWare ESX server -- the performance is excellent! Drupal itself is very snappy and the Cake applications are very responsive. All page loads are under 3 seconds (my target), with the exception being pages with a LOT of data.

You can work with Drupal's API perfectly fine as Cake is executed in the same space as Drupal. We use this fact in some of our small apps that need to know what user they're dealing with, so Cake just pulls data out of the $USER global from Drupal.

The benefits of using cake definitely outweighed the complexity increase. In fact, the complexity increase was pretty negligible as I no longer had to do much consideration of authentication and authorization against our systems (LDAP), as Drupal takes care of that for me. Also, it was easy to integrate the Cake applications with Drupal styles and have a very consistent look, which took care of a lot of the normal UI considerations we were having with other custom apps (ie: things are too ugly :) ).

I see a Drupal Module and a Cake app running inside Drupal as two different beasts. If I wanted to add functionality to Drupal, like add a new content type with custom handling, I would use a module. If I wanted to write an application that I wanted to "live" within a Drupal site, I would use Drake/CakePHP.

Now, your question was mostly about a reasonably complex application. My assumption is that a reasonably complex application's benefit to existing inside Drupal would come primarily from relying on Drupal's many charms, including authentication/authorization handling via user/role-based security, content type management, views (I love views!), exposing data in blocks, etc. Saying this, my initial answer would be to write it as a Drupal Module, because I would likely want my data to be visible to Drupal as a content type to open a world of powerful managing of the data, and CakePHP models will want to talk to the database directly. While this isn't an insurmountable problem, I'd think at first that this alone would be enough to dissuade me.

You could override AppModel and teach it to talk to Drupal's database layer, though (which might actually be a VERY interesting experiment with Drake). Or, if you weren't worried about your data being visible to other Drupal modules, this wouldn't be a consideration. In our applications, we've (so far) not been worried about exposing our data to Drupal (probably quite the opposite, both for security reasons and based on the fact that CakePHP talks with a completely different database server than Drupal), but I can foresee the day that we might want to.

Could you write an effective, reasonably complex application with CakePHP in Drupal via Drake? Absolutely. But you might have to invest some time on integration between the frameworks if that's a concern of yours. All in all, that's a question best answered in your context, not broadly.