Why I Don't like CakePHP

I’ve used CakePHP for a lot of projects now. Verdict: there’s no comparison to Ruby on Rails. Ruby on Rails is smartly integrated, well-designed, and sits on top of an elegant language. CakePHP is an admitted ripoff of Rails that sits on a popular but terrible language. It copies Rails – almost randomly – without copying any of the stuff that makes Rails great. PHP is a language plagued by indecision, delays, and paradigms from the last decade.

What makes Rails great?

  • An ActiveRecord implementation that isn’t brain-dead. The Object Relational Model is, you know, actually object-oriented.
  • Lazy-loading of records that allows as-needed fetching of model associations instead of a dumb and unintuitive $recursive variable.
  • Actual documentation that doesn’t suck (not that it didn’t suck in the early years). Cake’s has been getting better lately, but it’s still got a long way to go.
  • Massive community of great plugins.

What makes CakePHP awful?

  • Arbitrary and seemingly random nesting of HTTP input parameters. It gets to the point where I sometimes access $_GET and $_POST directly, and just carefully sanitize the data myself.
  • Default routing does not use REST, and is difficult (but not impossible) to coerce into anything resembling REST.
  • Model instances are represented as PHP arrays instead of objects. So it’s like a struct, except uglier, and you can basically set a few class variables on the model, then call a class method, which simulates an object method. Nice. The CakePHP core team’s position on this is that it is made this way so users cannot call instance methods in the view. So not only is the decision based on stupid reasoning, it’s not even a technical one.
  • Ridiculous schema manager that has noble intentions, but tries to automate too much. Instead of making you write your own schema changes like Rails does, it tries to figure it out on its own — with disastrous results. Let’s say you rename a column and want to port that change over to another database using the cake console. Instead of renaming, it will drop the column and make a new one, which means — yes — all your column data is now gone. This is because there’s no way to tell with certainty the difference between a rename and a drop/add after it has already happened. But it matters.

One thing I definitely get the sense of is that Cake doesn’t even try to hide the fact that its cloning Rails in PHP, but it’s at a disadvantage from the start because PHP’s syntax is just so much worse. And they use arrays to represent objects. And PHP’s array syntax is terrible. Unbelievably terrible.

I spend the majority of my time in Cake trying to manipulate arrays-of-arrays-of-arrays-of-arrays that are supposed to represent some kind of shoddy struct, then mangling with model associations that require about 5 nested arrays to define. Add to this the fact that CakePHP tries to “innovate” its way around some of its shortcomings in a less-than-brilliant way (like, um, $recursive) and you get a steaming pile of garbage that’s only marginally better than just coding a PHP project from scratch.

Rails’s smart design has come at a cost. In the past, they haven’t been shy about breaking backwards compatibility, sometimes in a big way, to cut out cancerous ideas before they take hold. It’s a community that acknowledges mistakes and embraces their eradication. And Ruby is an elegant language with strong design and is under active development. PHP on the other hand has languished for years, most notably with a critical security bug called $register_globals. On top of that, they’ve been slow to introduce object support, type-checking, and sometimes make terribly confusing decisions (like the decision to call a feature overloading that has absolutely nothing to do with method overloading in the traditionally accepted sense of the word).

To be fair, here’s what I don’t like about Rails (and Ruby):

  • Massive list of reserved variable names, which of course will throw a cryptic and seemingly unrelated error if you use them.
  • Concise syntax that sometimes resembles perl. Yes, perl. It’s that bad.
  • Bizarre decision to use “end” to close blocks instead of something sensible, like um, anything else. More typing for no good reason. The cherry on top that makes this not OK is that while its illegal to define a variable named “end,” its fine to define a function named “end.”

13 thoughts on “Why I Don't like CakePHP”

  1. cakePHP sucks. Why? Their own blog tutorial – ambiguously written – results invariably in error messages:

    Error: PostsController could not be found.
    Error: Create the class PostsController below in file: appcontrollersPostsController.php

    If those idiots cannot write out a simple “hello world” tutorial … one wonders what else they punted on.

    PHP is an old, old friend. codeigniter is not, but at least it works out of the box and is documented by humans rather than imbeciles.

  2. Cake php sucks. Still asking why? Their examples are difficult to understand. They have 15 minute tutorial but setting up instruction will take you a day and you will realize that their instructions are not that helpful.

  3. Hi Peter, how are you.
    Can you help me in building a recipe website.
    have you seen the website tastespotting.com, foodpair.com
    I really like the pattern n formats instead of the regular stuff and then use the header in two lines for the rest of categories.

    Just a heads up
    I looking frwd to a website and mobile app for all OS n tab with
    Compulsory registration which cld be possible from all possible social networking sites Users should be able to register any how in any which way possible, by a standard email process OR through social networking sites like FACEBOOK TWITTER LINKEDiN PINTEREST and all such sites also if possible Registration through mobile phone shld be made available.
    Mobile Apps shld not have much of a difference than the main site.

    International Payment Gateway shld be user friendly with emphasis on internet banking and any visa master or gift n all possible debit cards and could be added n if IMPS like Mpesa can be added.

    The Recipe Management and Socializing Application shld allow registered users to view unique recipes of other individuals who are passionate about cooking.

    HOWEVER the recipe management application shld only allow cooking enthusiasts to share edit existing recipes and repost and promote recipes by email they would like others to prepare and enjoy with their friend and families – ONLY if they make specific payments.

    Regards
    Kishor

    1. Kishor – sorry, I don’t consult on projects like this and I don’t freelance. Your best bet would be to flesh out your idea into a detailed specification and go somewhere like freelancer.com to submit an RFP for bids. The most difficult thing here is to have a thoroughly complete and unambiguous spec so that there’s no wiggle room for the developer to technically meet your requirements without actually giving you what you want. This is actually really hard.

      Or if you’re trying to do it yourself, your best chance of success is finding a platform like WordPress, Drupal, or Magento that you can bolt your functionality onto. I am not sure what your experience level or approach is, so I can’t be much more specific than that.

    1. hi,

      When I run the command, “cake bake”, why does it not go into the cake shell? It runs it, then I’m back to the dos prompt?

  4. cakephp is a piece of shit, maybe? I dunno , can’t get the f****ing shit to work properly to actually assess it. All the tutorials are out of date.

  5. This article is 7 years old now and where is Ruby? Nowhere to be found. And where is PHP? Everywhere. Good luck finding a job coding in Ruby or even Python. You’d be better off learning ColdFusion. LOL

    1. I’m not sure what point you are trying to make? There are a lot of things you could criticize this ancient post for (and you could’ve easily sounded smart, since you are talking to someone in 2010), and I would’ve wholeheartedly agreed with you on. But PHP was a garbage language 7 years ago, and CakePHP was always a garbage framework. Nevertheless, this wasn’t a prediction of doom for PHP. For what its worth, I’m gainfully employed at a Ruby startup today, and doing talks in the local Ruby community.

      But if you’re going to make random unfounded claims, PHP has been on a long slow decline for more than a decade:

Leave a Reply

Your email address will not be published. Required fields are marked *