views:

1312

answers:

2

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?

+16  A: 

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
Jim Puls
"without doing any of the stuff that makes Rails great" - I'd like to hear more about that. Great response!
I'd like to know more about that too - frankly they're just both MVC frameworks that use an activerecord implementation
wizard
There, I edited the answer to talk about it.
Jim Puls
I completely agree with what Jim said. CakePHP just feels like the poor man's Rails. Having to deal with gorgeous array structures for just doing everything piss me off. There is no "magic" lazy loading, so you have to manually set which recursion level you need. There is no built-in package manager. Code generation is not extensible... and a lot of cons.
knoopx
just on a point of note, it doesn't rely on `mod_rewrite` at all. With it turned off (as I have now, since I'm developing for IIS), your URLs just look like this: `example.com/myapp/index.php/users/view/1` instead of `example/myapp/users/view/1` .. no huge problem IMO.
nickf
A: 

I haven't worked with CakePHP, but my impression of it isn't too good. If you're after a Railslike framework for PHP, I think you may be better off looking into Symfony. It's probably a bit more complicated to get started with, but the whole project seems much better organised than CakePHP.

Of course, take with a grain of salt, since these things are quite subjective.

troelskn