Four reasons to hate CakePHP

A follow-up has been posted here

Before starting a project recently, I spent some time doing some research comparing CakePHP and Zend Framework for rapid development.  I noticed that of the few articles out there, not many of them where able to offer any advice on using either framework for a new project.  In most blogs, it seemed to come down to preference.  My goal today will be to steer you away from Cake.

This article is intended for those that are familiar with the concept of rapid application development, and the benefit of using a framework such as Zend or Cake.  If you want more information on why you would use such a framework, This article is outside of that scope.

It's worth mentioning that CakePHP and Zend Framework aren't the only popular open source rapid application frameworks out there.  I'm only focusing on these two frameworks because I have the most experience with them, and can offer useful insight into their strengths and weaknesses.  If you're interested in other frameworks, have a look at any of the following.

Cake is Heavy

Staying out of your way is a very important for many aspects in life, including your application's third-party framework. You want something that provides functionality and structure, but allows you to fulfill your own needs in your own way.

Cake is no low-calorie meal

There's nothing lightweight about it. Cake tends to get in the way of your application by requiring your application to be built on top of (instead of along side of) itself. When cake is bootstrapped (configured), it will look for your application specific configuration files in a hard coded file location that it expects. Although you can predefine the defines (which is a whole-other reason to avoid using cake) it uses to determine paths, you'll never be able to completely seperate cake from your life without modifying cake itself.

Code and Feature Management

One of my cleints' websites is was written on top of one of the Cake 1.2 alpha releases from a few months ago.  (By the way, did no one tell the developers that in software engineering "alpha" release is not meant for the public?) I recently upgraded to 1.2 Release Candidate 4 and had a few problems.  This is to be expected when you're using any non-stable version of anything, but what I didn't expect was API changes. I don't mean additional features, I mean changing APIs.  Granted they were few and far in between, but they were still unexpected.

Hanging on to Old Times

The most annoying thing to me is that Cake uses PHP4 style objects. I feel safe in saying that any community software being developed today that believes hindering best practices in order to support an obsolete (in the loosest of terms) version of software is not very forward thinking.  No class members or functions have access modifier, and I don't remember seeing any type hinting whatsoever.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// This is Bad!
 
class Animal
{
    var $kingdom = 'Animal';
 
    function foobar()
    {
        //do something very private
     }
}
 
// This is GOOD!
 
class Animal
{
     private $_kingdom = 'Animal';
 
      private function foobar()
      {
          //do something private
      }
}

No Namespace Consideration

Cake uses very generic class names with no consideration for names pace collisions. By using cake, you're forcing yourself out of using generic class names in your own application (which is a better place for generic names to be!). Want to name a class `Controller`, `App`, or `Model`? Too bad -- cake has claimed those names for you!

Another horrible practice of Cake's is using global functions. Hsughughugh. I cannot begin to tell you how painful and fragile this is. All it takes to cure a few of the problems this creates is to wrap them in an abstract class! I don't know why they would rather have the function uses() in a global namespace instead of wrapping it in a class as `Cake::uses()`. Some (maybe most?) have been fixed in RC4 (you use `App::import()` instead of `uses()`), but they still allow the abuse by keeping the functions there.

Conclusion

If you are reading this article, you're probably at a crossroads between using CakePHP or using some other suite. I could go on and on about why I personally hate cake, but when it comes down to it, the decision is yours. Despite my gripes, Cake is still a good tool to get a simple website up and running quickly in a structured manner, without reinventing the wheel. Just make sure your website will never need to be scalable, and that its codebase will never grow beyond the small flexibility it offers. I'm personally experiencing this pain right now.

Great for mom & pop, but corporations shouldn't dare

That's how I once described my thoughts on using Joomla as a foundation for websites to a potential client. I think I'll go ahead and reuse that for this article.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Printed from: http://ajbrown.org/blog/2008/12/22/four-reasons-to-hate-cakephp.html .
© © A.J. Brown 2012.