.8 Reasons to hate CakePHP
I'm still bored and lacking posting ideas, so I figured I'd give a hyper-critical breakdown of "Four reasons to hate CakePHP" by A.J. Brown. Let's get right into it.
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.
Granted I'm not really the target audience here, but I can keep an open mind. I can't make the same promise for my cat (coincidentally named CakePHP), who will most likely hiss and spray urine at my monitor as I read.
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.
On the same page so far. Let's see how this is a negative in respect to Cake.
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.
I'm not really sure what the difference is between "on top of" and "along side of". I'm guessing this is the difference between using a framework and a library. I blame Zend for confusing this issue.
When cake is bootstrapped (configured), it will look for your application specific configuration files in a hard coded file location that it expects.
Just so I'm clear: A.J. wants a framework that "provides functionality and structure" but complains that config files are in a certain location. Isn't that part of the structure? Also, I think A.J. and I have a different definition of "heavy". This section should have been titled "Cake is Unflexibilityness."
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.
I don't understand why people would expect to be able to write an app using a particular framework and then be able to separate from that framework at some point in the future. Thats like switching to an unprimed canvas after painting your masterpiece on a titanium dioxide and calcium carbonate, bound with a thermo-plastic emulsion primed canvas. Who does that?
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?
A.J. has a point here. When an open source project releases an alpha version they should, at minimum, require a secret handshake before allowing the community to access it. Also, I remember when Cake 1.2 alpha first came out I didn't want to use it, but then Nate showed up at my house and bullied me into it.
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.
To summarize: A.J. used an alpha release (probably against his will), jumped something like 17 releases to RC4 and was surprised by minimal API changes.
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.
A somewhat legitimate complaint to those of us who've moved on to PHP5. I see this all the time and I don't think people realize that even though the framework is PHP4/PHP5, there is NOTHING preventing you from writing YOUR code in PHP5.
No Namespace Consideration
Cake uses very generic class names with no consideration for names pace[sic] collisions.
Pace is very important when dealing with rapid development frameworks. The fact that Cake has no consideration for pace leads to thousands of collisions and hundreds of deaths a year. Factor in the increased alcohol intake of CakePHP developers and you have a recipe for disaster.
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 somewhat legitimate complaint. I actually hit this issue once...in two+ years of using Cake...and moved past it in like 5 seconds. Here's a quick guide for some alternate names:
Controller: BossMan, Model: SheWhoWillNotLookAtMe, App: ThankGodImNotUsingJava.
Another horrible practice of Cake’s is using global functions. Hsughughugh.
I think "Hsughughugh" is an aggravated pounding of the keyboard. Which is odd since A.J. wasn't so aggravated that he didn't miss capitalizing the first word. Also check out the letter selection. Seriosly, try randoming banging at your keyboard. asdfhnasdlk. Again: k;lajsdfaksfd. Generally you get some mix of the home keys. A.J. must be using one of those crazy new ergonomic keyboards.
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()`.
Um, this was changed like 3 releases ago.
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.
This is just silly. He complains about something from an old version, then acknowledges it's fixed. You know what I hate about watching TV? Having to get up to change the channels. True this was fixed with the invention of the remote control, but they still left the ability to change channels on the TV itself.
Also, I'm pretty sure A.J. complained about changing API earlier in this same post. But now he wants the function removed.
Conclusion
If you are reading this article, you’re probably at a crossroads between using CakePHP or using some other suite.
Or someone who enjoys nitpicking other blogs.
I could go on and on about why I personally hate cake, but when it comes down to it, the decision is yours.
Unless Nate puts you in an armbar.
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.
CakePHP is actually against developing serious sites using the framework. They keep a running list of the offenders here.
Just make sure your website will never need to be scalable, and that its codebase will never grow beyond the small flexibility it offers.
Oh shit. Cake just got Rudy'd.
I’m personally experiencing this pain right now.
You think that's pain. Just wait until Nate puts you in a figure four leg lock and forces you to write "25 things I love about CakePHP in haiku format."
I will give credit to A.J. for breaking from the "Hate CakePHP Playbook" and not slamming the documentation. So +1 for that, +.8 for legitimated points, -138 for weak points. I give this article a 2 out of 10 (not an aggregate of the points).

22 Comments
::Subscribe::
anyway.. keep it up. subscribed!
@Kjell - The "read more" is the BlogFollow Plugin. I'll pull the url from your previous comment and it'll go away.
@nate - sounds like a religious war-ish statement
By the way nate, thanks (indirectly) for the link... I actually agree with this chart:
http://debuggable.com/posts/cake-vs-zend-vs-symfony-vs-igniter:4942b243-85bc-404a-afc9-34aa4834cda3
well done Matt.
Though, to be fair, you are completely and utterly wrong: Many modern TV sets do not have the option to change a channel without the use of a remote. So, you might want to rephrase yourself there, mate!
Heee-larious...
I clicked on the "Maybe I was too hard on CakePHP" pingback, and I got this:
The following error occurred:
exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (blog)' in /usr/share/php/ZendFramework-1.7.1-minimal/library/Zend/Controller/Dispatcher/Standard.php:241 Stack trace: #0 /usr/share/php/ZendFramework-1.7.1-minimal/library/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/www/ajbrown.org/application/bootstrap.php(42): Zend_Controller_Front->dispatch() #2 /var/www/ajbrown.org/public/index.php(8): require('/var/www/ajbrow...') #3 {main}
What's up with Zend? :D
"Controller: BossMan, Model: SheWhoWillNotLookAtMe, App: ThankGodImNotUsingJava."
Add new comment