Ruby on Rails and CakePHP Comparison

Thank you for writing this up, Sean.

I have investigated this myself and found exactly what you found (mainly
concerning CakePHP). Maybe with the exception of Console (or rather
Bake)
support in CakePHP. I specifically tried to contribute to this and was
really annoyed at the maintainers of the project. Without going into
details they were very (overly) defensive about their project. I tried
to
DRY up the source code a bit and that was not at all what they wanted.
Especially the project lead PhpNut_. So we got into an hour long
discussion
(in #cakephp) with the result of me deciding not to waste anymore time
with
CakePHP :wink: It was just too hard for me to contribute.

Also, since they try to emancipate themselves from Rails, you cannot
really
argue like “but Rails does it that way, could we do something like that
in
CakePHP?”. You will only get answers like “don’t you dare bring up Rails
here” or “oh no, he mentioned the R word”. This really turned me off.

It is funny. If you are like me and like to use both you seem to get
heat
from both sides of the fence…

Back to the Integrated Testing question, I think the lack of
documentation really killed CakePHP for me. We had the answer as “No
testing at all” until we ran into it by accident. As of last week,
there was NO mention of testing in the online docs at all.

This was the biggest issue for me, too. Actually you can formulate this
even broader. The part of Rails which tries to bring you to use better
work
practices is almost completely missing from CakePHP. Be it testing,
structure or the other many little things that Rails does. But this is
missing in almost all (I know of no exception) RoR wannabes.

I tried to talk to them about this, too, but there was actually no
understanding of why you would need that. I got the feeling that they
actually didn’t quite know what I was talking about. This probably stems
from the fact the core CakePHP team has not actually used RoR
extensively
enough to know what all is done in RoR and what of it could be used to
make
CakePHP better. When it comes down to it, this is the main issue which
is
responsible for all other shortcomings of CakePHP or any other RoR
inspired
php framework. RoR has gotten so huge that you can’t easily replicate it
in
another language with major effort in both worlds.

My current php favourite is http://www.codeigniter.com/. They have some
good documentation. And their goals are in line with mine. From their
website:

Who is Code Igniter For?

Code Igniter is right for you if:

  • You want a framework with a small footprint.
  • You are not interested in large-scale, monolithic libraries, like
    PEAR.
  • You need broad compatibility with standard hosting accounts that run a
    variety of PHP versions and configurations.
  • You want a framework that requires nearly zero configuration.
  • You want a framework that does not require you to use the command
    line.
  • You do not want to be forced to learn a templating language.
  • You need exceptional performance.
  • You eschew complexity, favoring simple solutions.
  • You need clear, thorough documentation.

They have very good video tuts, too.

-Sascha E.

Daniel ----- wrote:

<%= render :partial => “menus” %> #=> will include the _menus.rhtml
file at
that point in the view.

Alternatively you could write a helper method and put that in
application_helper.rb and then call it in your layout

<%= menu_helper_method %>

Hope this helps

Great. :slight_smile: Much the same as an php include then.

Wow, I didn’t expect this response. Excellent!

Thanks for correcting me on some points. A lot of what we didn’t like
really comes down to preference, but, from your response, I’m seeing
that a lot of what we may have had misconceptions about is simply not
documented.

On 6/12/06, Larry E. Masters [email protected] wrote:

I choose not to include any code outside of the project in the releases.

Understood. I prefer it to be included. Less barrier to entry. I
like downloading one package and then running with it.

Which actually brings up another point I didn’t address before. I
REALLY like how Rails comes with a server and is just ready to go.
Having not worked with PHP very much in the past 2 years, I wasn’t up
on my Apache configs for getting PHP running. For big-time PHP
developers, it’s likely not a big deal. They do it all the time. But
for someone new to this (or coming back to this), I found it difficult
and wondered why I was wasting so much time trying to decipher the
docs just to get things running.

Caching: CakePHP only has view caching.

No true, CakePHP can also cache models and meta data of the tables. The
view caching if used properly, reduces all calls to the database, but
view caching is different from the model and meta data caching

An example of the docs not being up to snuff:

http://manual.cakephp.org/chapter/17

This link is listed as “View Caching” in the manual. I didn’t see
anything specific (at the time–this was early last week) about any
other type of caching.

Although a separate project on cakeforge.org it is available.
Cake Migrations:
http://cakeforge.org/snippet/detail.php?type=package&id=15

Good, but, again, barrier to entry.

Environments: No real separation of environments (prod/dev/test) in
CakePHP.

Not correct:
app/config/core.php
app/config/database.php

I saw those, but didn’t see any documentation. I don’t think it’s
clearly spelled out. Nothing about the advantages of doing this.
Again, Rails comes with 3 environments already set up, so you’ve got a
bit of a guide-book to get going. Also, maybe I’m being picky. :slight_smile:

Join models: None in CakePHP. Rails has HABTM and has_many :through.
All tables are models in Symfony, so that’s almost the same. More
like HABTM with extra info in the table. Propel, Symfony’s ORM
engine, is actually quite interesting. (Though, I prefer
ActiveRecord.)

CakePHP handles all type of association hasOne hasMany belongsTo
hasAndBelongsToMany. CakePHP also has recursive associations that allow
you to create very complex hierarchies in a very simple way

Sorry, I should have been more clear. The relationships and
associations are there, yes. It’s the added join model (as opposed to
a join table) that we didn’t see.

Our mail list grows daily with users and our irc channel is also a very
good place to get immediate help with a problem you may run into.

Excellent to know. It’s obvious that there is a growing community
around CakePHP, which can only be good for development and
competition.

Also about testing:
I wrote the test suite for CakePHP and at one time had it included in
the core, but separated it as its own project since people who use TDD
(Test Driven Development) would be able to install the test suite and
not everyone sees the advantage of using TDD. The suite itself is very
well integrated into CakePHP and a simple upload of the package is all
that is needed to use it

Again, the barrier to entry. Maybe I’m biased or spoiled, but now
that I feel like I’m developing in a more agile way, these things are
required, not just nice to have. If I have to constantly download
extra pieces (Ajax, migrations, test suite, etc), well, it’s a real
turn off. But if your users don’t mind, then it’s obviously not a big
deal.

CakePHP and RoR are tools of the “trade” if you will, and like any trade
you use the proper tools for the proper job. Does RoR or CakePHP work
for every project out there, No, and I do not see there ever being a
“god” framework to do it all. I use RoR, but develop CakePHP along with
a one other core developer. And IMO, which is a little biased, say we do
have the best framework for PHP applications. We also have a document
team that is starting to create some very useful documentation

Agreed. The right tool for the job.

The documentation is really what killed me. I think a lot of people
coming to RoR from straight web programming realize they have to learn
a lot about Ruby as well as MVC. The PHP developers I’ve spoken with
(by NO means a representative sample) have felt like, well, they know
PHP, and this MVC thing is all the rage, so it’s a no-brainer to paste
old code into the framework.

Having full documentation for the framework to show people how it’s
used and why it’s better to use MVC than whatever they’re currently
doing is going to be huge for you.

Even having said that, from what I’ve seen, CakePHP is the easiest to
use of the PHP frameworks (no, I didn’t look at all of them). So
you’ve got something good going there.

I think if you pushed TDD onto people, or at least led by example,
you’d have more tests in the framework, which could then help generate
some rudimentary documentation you’re lacking.

Anyway hope these corrections help.

They certainly do! Thanks very much!

Sean

On 11-jun-2006, at 18:23, Sascha E. wrote:

Choose the right tool for the job.

Yes. But I know that

a) I don’t want to make distributable web apps in the near future
b) I don’t want to make ANY use of PHP as a language, because after
Ruby it just feels like a big blob o’ functions.

Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl

On Mon, Jun 12, 2006 at 10:22:40AM -0700, Tom M. wrote:

Like what? And what can Ruby do that php can’t?

PHP && !Ruby:

  1. Simple templating (<?php include 'header.html' ?>)

Just out of curiosity how is that different than:

<%= render :partial => ‘header’ %>

That’s not part of standard Ruby. Note the two items being compared.

  • Matt

On Jun 12, 2006, at 2:49 PM, Matthew P. wrote:

Rails.

That’s not part of standard Ruby. Note the two items being compared.

  • Matt

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

def include(path)
eval(File.read(path))
end

<%= include “…/foo.rb” %>

-Ezra_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

On 11-jun-2006, at 15:48, Ross R. wrote:

Ruby

+2


Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl

On Mon, Jun 12, 2006 at 04:33:05PM -0700, Ezra Z. wrote:

There
Just out of curiosity how is that different than:

<%= render :partial => ‘header’ %>

That’s not part of standard Ruby. Note the two items being compared.

def include(path)
eval(File.read(path))
end

<%= include “…/foo.rb” %>

I’m so not explaining myself properly here.

To get to the point of being able to use <%=, there’s a bunch of other
stuff
that you need to do – it’s not nearly as simple as “apt-get install
libapache2-mod-php4” and then naming your files as foo.php. That is,
erb-style escaping isn’t inherent to the language, it’s an extra thing
with
extra work needed.

Also, I don’t think your include() method works quite the same way as
PHP’s
include()…

  • Matt

Matthew P. wrote:

On Mon, Jun 12, 2006 at 12:23:35AM +0200, Pål Bergström wrote:

Like what? And what can Ruby do that php can’t?

that you need to do – it’s not nearly as simple as "apt-get install
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Either way, this has become just a Ruby vs PHP discussion, which is
getting off topic, but along that line, I will (if I have a choice)
never again touch PHP. It’s the definition of a language gone wrong, and
when I’m using it anything I’ve ever made, no matter how hard I try,
always feels convoluted and also a hack. Ruby on the other hand has been
solidly designed from Day 1 to be a full pure OO programming language
with tons of niftly little features and completely dynamic.

CakePHP is probably a really good framework for those who love PHP. It’s
modeled after Rails, but from what I’ve seen it’s missing the one
feature that really makes Rails: code generation. CakePHP looks to get
back into the ‘configuration over convention’, which will probably be a
severe stumbling point for those deciding between CakePHP and Rails.
Also, the metalanguage capabilities of Ruby make classes a good bit
cleaner than Cake’s way of redefining methods for stuff like ‘has_many’.

Oh yeah, and ruby script/server.

Jason

On 6/11/06, Benjamin A. [email protected] wrote:

From a development standpoint, what are the features that make Ruby on
Rails a better choice compared to CakePHP?

Sorry for the late reply. The other day when I saw this post I
contemplated typing up a long reply, since I just came out of a
painful project involving CakePHP, but I was too tired (and frustrated
of even seeing the word “CakePHP”) to comment.

For the aforementionned project, CakePHP was tried because the client
explicitly insisted on PHP (something about having in-house PHP
programmers, or that they were easier to come by – a pretty terrible
argument to begin with, considering that just learning the CakePHP
framework is probably more difficult for the average “PHP programmer”
than it is for a solid programmer to pick up on Ruby and Rails).

CakePHP tries very hard to be like Rails, but ultimately, it fails.
It fails primarily because PHP is not Ruby. There are millions of
reasons why Ruby and Rails fit better than PHP and CakePHP, but to
make a long story short: we spent God-only-knows how many hours just
hacking away at the innards of the CakePHP framework to make it behave
how we wanted it to. CakePHP’s “models” are really not the same as
Rails’ ActiveRecord, and we found ourselves unfortunately adopting
static (procedural) APIs for a lot of the model functionality (you
don’t pass model instances around in CakePHP, but multi-dimensional
arrays).

Working with CakePHP, we also missed gems and plugins. A lot.

It’s funny that after we completed (it’s actually still in
pre-deployment) our CakePHP project, we found that we ended up
hackishly implementing a lot of the cool stuff that now ships with
latest Rails (most notably acts_as_tree and similar).

Anyway, don’t take my (or anyone else’s) word for it: try both, give
it a week or two, and you’ll immediately see the difference.

Hi, I would like to see this thread moved to another list being that
this
should be a list about Ruby and/or Rails.

Thank you,

-Conrad

Jason R. wrote:

CakePHP is probably a really good framework for those who love PHP. It’s
modeled after Rails, but from what I’ve seen it’s missing the one
feature that really makes Rails: code generation…

No sound and my first attempt at using a video capture tool:

This shows code generation using scripts/bake.php

…CakePHP looks to get back into the ‘configuration over convention’, which
will probably be a severe stumbling point for those deciding between CakePHP
and Rails.

I disagree on this, CakePHP has little, if any, configuration.
Upload it and it works.

Few articles:

http://blog.usweb.com/archives/phps-answer-to-ruby-on-rails-cakephp/

Larry E. Masters aka PhpNut

i have questions regarding to the two frameworks…for your information,
i’d assigned to develop e-portfolio system within 6 month…and i have to
decide either Ruby-on-rails or cakephp…i never use ruby b4 and i don’t
know how ruby works…i try to install ruby…but i can’t install
gem…seems my computer didn’t reconize gem…is it relevant for me to use
ROR or just use cakephp?is it possible to learn ruby in short time?

Do yourself a favor and say goodbye to PHP and hello to Ruby. You won’t
regret it.

Try to read “Agile Web development with ruby on rails” You’ll learn it
in just two or three days!

If you’re a Ruby newby (like me!) then before digging into Rails I
think it would be a good idea to take a look at David Black’s
outstanding Ruby for Rails:

It’s really great for helping you come to grips with Ruby as a language
and how you can use it with Rails, the framework. I started reading it
about a month ago and now I can actually read and understand what’s
going on in (some of) the Rails source code. Highly recommended…

I second James’ suggestion.
There’s plenty of online Rails Tutorials (here are the top 12), but get
the 2nd edition of “Agile Web Dev with RoR” if you can… it’s well
worth the money.

The Ruby book 1st edition is online…
http://www.ruby-doc.org/docs/ProgrammingRuby/

Bart

hi gmacgregor,

I am also a newby, I’ll take a look at your recommendation. Have you
try Agile Development with ROR? It is also great even for a ruby newby
like me. How do you compare the two books?

james

From a development standpoint, some of the differentiating features are:

  • Rails Community is excellent and can answer any questions that come
    their
    way.
  • Ruby. It is a language built around solid object-oriented design,
    whereas
    PHP has OO features bolted on. Even though PHP5 significantly changed
    the
    underpinnings of the interpreter, it still feels clunky compared to
    Ruby.
  • Rails. The framework itself is at 1.2 and moving quickly toward 2.0.
    Cake
    is nowhere near a stable 1.0 release.
  • Testing. The Ruby community embraced test-driven development and Rails
    has
    it baked right in. PHPUnit is no match for Test::Unit (IMO), and tools
    like
    ZenTest or rSpec are incredible for improving the quality of your
    applications.
  • Publications/Events. There are plenty of PHP events and plenty of PHP
    books, but I don’t think you’ll find a Cake event that parallels
    RailsConf.
    There are now a number of great books about developing Rails apps, many
    of
    which have been mentioned here. I’m not aware of so rich a set of
    learning
    materials for Cake.
  • Rails apps are harder to deploy on budget shared hosts.
  • Server resources. PHP is hardly a zero-hit on the server, but because
    mod_php is often loaded in shared Apache environments, people take it
    for
    granted.
  • No IDE. If you are looking for an IDE-driven development, Rails might
    not
    be for you. Cake probably isn’t either, but you could conceivably use
    the
    Zend IDE.

I built one app using Cake to bench test it against Rails, and
PHPonTrax. I
truly regret the decision to follow through with that. I’ve since
rewritten
in in Rails, spending 1/4 the time and adding features along the way.

If you’re up for learning Ruby and want to use a sound MVC framework,
Rails
is a very productive one. My opinion is that Cake is not where it needs
to
be. Further, I do not believe PHP is a language conducive to the next
generation of Web applications.

Just my .02 (USD)

Benjamin A.-3 wrote:


View this message in context:
http://www.nabble.com/Ruby-on-Rails-and-CakePHP-Comparison-tf1768712.html#a8516343
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

james_027 wrote:

I am also a newby, I’ll take a look at your recommendation. Have you
try Agile Development with ROR? It is also great even for a ruby newby
like me. How do you compare the two books?

The Agile book throws you right into Rails and gets you going. It’s
good because you’re doing something (building the depot application)
and the “magic” of Rails is thoroughly explained. However, I didn’t
really get some of the basic concepts because I didn’t know a thing
about Ruby – which is of course key since it’s the language behind the
framework!