views:

5547

answers:

17

I'm going to be switching back and forth between Ruby on Rails projects and some as-of-yet undecided PHP MVC framework projects.

Which of the PHP MVC frameworks out there (CakePHP, CodeIgniter?, others?) is most similar to Ruby on Rails in that the most conventions, locations, workflows, etc are preserved?

I'm looking for the similarity in the way things are done such as directory structures, conventions, etc, not a pros vs cons in speed, extra features, etc.

+22  A: 

In my experience with both PHP (5+ yrs) and RoR (1+ yr), CakePHP is the closest MVC framework to Rails that I have found for PHP.

That being said, there will still be conventions to learn/unlearn and differences between the frameworks, but if I were taking on the task of bouncing back-and-forth, I'd use CakePHP.

Steve Paulo
+10  A: 

Here's an old (April 2007) Ask Metafilter that had some folks contributing frameworks to look at: CakePHP, Symfony, Mojavi, Code Igniter are the PHP MVC frameworks recommended. They suggested CI and Symfony over Cake.

Tim Howland
+6  A: 

CakePHP is the closest. Your models/views/controllers directories will be the same. All of the concepts like routes, active record, plugins, and scaffolding are similar. The active record implementation supports associated models (one-to-many, many-to-many, etc). This is something that is lacking in other php ORM implementations.

I have coded projects in both CakePHP and Rails.

tyshock
+7  A: 

CakePHP has one major flaw that I think makes it dramatically less useful as a MVC framework: the Model layer does not use Objects to represent data (which is to say, it does not actually implement the active record pattern). Because of this, associations like HasMany are less robust, and it's much less obvious how to keep model-specific code from creeping to your Controller layer.

Symfony, at least, does not have this problem-- they use a third-party active-record implementation called "Propel"

jes5199
The lack of model objects in cakephp is a bummer. ORM results are arrays which cannot benefit from relations, lazy-loading, or anything else useful.
Xeoncross
+1  A: 

I've got a few years experience in RoR and I have investigated most of the PHP frameworks for a PHP project I was working on and CakePHP came out the closest to Rails that I could find.

The best part of Cake is that they've emulated most of the great designs and time savers Rails has.

Dan Harper - Leopard CRM
+6  A: 

Have a look at Akelos, it seems to be a strict port of Rails

meleyal
+7  A: 

Actually someone is creating yet another Rails clone in PHP:

A PHP framework that "tries" to live up to what the good guys did with Rails, without the brain damaged results that the Cake PHP guys did.

Personally I'd go with Akelos: it's more mature and closer to Rails than its main competitors.

CakePHP was inspired by Rails, as I pointed out in an old article of mine, but it's inherently very different.

CodeIgniter is simpler, but does the job.

h3rald
+3  A: 

Beside everything that is said one should consider that a php-framework will never act like RoR can. So, a good php-framework should not try to copy RoR but to do things the php-way while using most of the patterns that makes RoR sexy.

I personally prefer cakePHP because it offers a lot of functionality while being user-friendly (read: developer-friendly) and therefore it should not be compared with CodeIgniter. CI is more like a basic-framework for MVC-Patterns missing a lot of features to build an application easily.

To compare CI and cakePHP a little bit, think of that: cakePHP is driven by a bunch of people doing nothing else but building cakephp (+ using it for some projects which makes it even more practically orientied). CI is just a by-product in the development of expression-engine. EE itself is a remarkable piece of software but i would not say that CI is.

d1rk
+4  A: 

In my experience, CakePHP is most similar to RoR.

However, I must point out that Ruby and PHP are very different languages; RoR wouldn't be the same if it were PoR. Each language has its strengths and weaknesses, and Rails plays on Ruby's strengths. Trying to take advantage of those same aspects of a different language that may not, then, be strengths will result in a framework that leaves much to be desired.

I think your question should be, "Which PHP framework is the easiest to use." I'm sure your head won't explode if you have to learn two different ways of doing things.

Lucas Oman
+3  A: 

If you are forced to use php, go with CodeIgniter. It's fast and easy to work with. It also has a wonderful and smart community of developers (http://codeigniter.com/forums). If you are not being forced to use php, make the jump to ruby. It's a wonderful language with many wonderful frameworks.

Kevin Kaske
A: 

SilverStripe (CMS) built on Sapphire (framework) claims the following:

Do you enjoy Ruby on Rails or Django as a way to quickly write stuff in fewer lines of code thanks to concepts like ActiveRecord, ORM and MVC? You'll love our Sapphire framework, giving you contemporary object-oriented goodness, focused on building database-driven websites. It runs on PHP (5.2+) so it's easy to learn and to find webhosting.

They just won the "most promising open source CMS award"!

tharkun
+6  A: 

I would argue "most like Ruby on Rails" is a silly reason to choose a framework.

PHP is not Ruby, and while it sounds nice having a PHP framework that works "just like Ruby on Rails", because the two are different, it'll never be the same..

I would recommend CodeIgniter because I found it a far nicer framework to use (compared to the others I tried), but my point is, try a bunch of frameworks and see which one you like the most!

dbr
+1 I've developed a few applications in CodeIgniter and a few in RoR and found that I can make applications faster in PHP than I can in RoR. Guess it's just personal preference really
WarmWaffles
A: 

I too would recommend Code Igniter. It has less restrictions than CakePHP and runs a little faster.

Jon Winstanley
+2  A: 

I am using CakePHP since last 2 years... I am haven't seen such framework ever. From above posts, I came to know about Akelos. I saw it... and of course it's an awesome Framework. It is almost equivalent to CakePHP (may be batter but not less).

Just because of these kind of frameworks, PHP is still our love. :)

Looking forward to a concrete reason to be shifted from CakePHP to Akelos.

Thank You all guys,

Jaydeep Dave

Jaydeep Dave
A: 

PHP on Trax http://www.phpontrax.com/

Tharen
A: 

One more vote for Codeigniter

Andrei
+1  A: 

You may look at yiiframework.com it is a good framework. Yii inherits spirit of conventions over configurations of Ruby on Rails

dimis283