How different is CakePHP from Ruby on Rails?

Lee Tang picture Lee Tang · Jan 30, 2009 · Viewed 9.2k times · Source

I almost never hear the word CakePHP without hearing the word Rails shortly afterwards. Are these two frameworks mainly similar based on how they adhere to the MVC model or do they have other significant similarities/differences?

One of the main attractions of Rails for me is how easy it is to do Ajax. Would that also be true of CakePHP?

Answer

Jim Puls picture Jim Puls · Jan 30, 2009

CakePHP is like a cheap, bastardized ripoff of Rails. It tries to be like Rails without doing any of the stuff that makes Rails great. It kinda feels similar, I guess.

CakePHP has an Ajax helper that does something similar to the Ajax-related helper methods in Rails, so yes, in some way, it's also true.

But CakePHP is really an exercise in futility: its authors wrote it so they wouldn't have to learn Ruby, even though learning Ruby and Rails together is probably easier than figuring out the monstrous mess that is CakePHP.

(This, coming from somebody who does CakePHP at his day job.)


Since y'all asked, my biggest complaint about CakePHP is how it manages to totally butcher the conveniences of object-oriented programming: sure, it implements the Active Record pattern just as much as Rails does, but it makes you pass around data structures.

I feel like any logical person would implement an ORM using faulting and dynamic loading of properties in to objects, which is exactly what ActiveRecord (the Rails library) does. The whole idea of setting a member variable called $recursive to determine which relationships to load is just plain flawed.

Being based on PHP is pretty fatal, too; you can't do anything with global state, you have to depend on mod_rewrite, you pay the startup penalty on every request. Sure, there's optimizations for any environment you're using, but still. People say Ruby is slow, but my own Rails apps run faster than their CakePHP equivalents, last I checked. I admit to being without data on this.

Worst of all, the bugs in CakePHP just about kill it for me. I could tell any number of stories about

  • the time we spent two days figuring out why CakePHP refused to connect to the right database host
  • the time half of our pages went blank because of the memory ceiling from using too many components
  • the amount of code that lives in our AppController because every component load costs several megabytes of memory
  • the black art of massaging data structures to make XML output work correctly
  • how we traced down the blank <javascript> tag that shows up at the end of every page