Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 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.

share|improve this question

closed as not constructive by Wesley Murch, gnat, Rikesh, Ivaylo Strandjev, Sankar Ganesh Feb 19 at 9:15

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

19 Answers

up vote 45 down vote accepted

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.

share|improve this answer

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!

share|improve this answer
2  
+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 Sep 7 '10 at 2:48

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"

share|improve this answer
3  
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 Aug 5 '10 at 22:56
1  
Fair point, but does CodeIgniter even have ORM at all? It had a very very light (almost useless?) implementation of it last time I checked. – Simon Jan 9 '12 at 5:05

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.

share|improve this answer
2  
This doesn't actually answer the question though? – icc97 May 19 '11 at 23:52

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.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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"!

share|improve this answer

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

share|improve this answer

You might want to try FUEL - It's a relatively new framework but has reached 1.0 Final!

Features look pretty awesome such as a CLI called OIL for RAD and performing routine tasks.

You should definitely check it out and read through the docs.

It's built by an amazing team which have been involved with CodeIgniter, Datamapper, PryoCMS, ExiteCMS

share|improve this answer

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.

share|improve this answer

As a Rails developer with experiencie using CodeIgniter and CakePHP, I could tell that CI 2.0 does not have any of the magic that Rails have. CI deprecated the scaffolding or generate resources feature that could help you have your app up & running as fast as in Rails, and neither as much useful libraries as there are gems.

I would not recommend you to use CodeIgniter if you're trying to feel the sturdiness of a web framework like Rails.

CakePHP has more restrictions and is slower than CI, just like Rails.

share|improve this answer

Have a look at PHP on Trax, which according to its website was formerly known as "Php On Rails" and

is a web-application and persistance framework that is based on Ruby on Rails and includes everything needed to create database-backed web-applications according to the Model-View-Control pattern of separation.

share|improve this answer

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

share|improve this answer

Most of the php frameworks are inspired by ruby on rails.When it comes to closest i must say it is "CakePHP". Reason:

  1. It follows the controller, model and tables naming convention same as ROR.
  2. Cakephp also creates created_at and modified_at automatically like ROR.
  3. Model, view, controllers can be generated through bakecake which is also similar to ROR.
  4. Thier folder structure are similar to ROR and many more.

On the other hand codeigniter is also an excellent framework based on PHP.

share|improve this answer

You should now consider Laravel. It is based purely off PHP 5.3, and has taken some inspiration from RoR.

Laravel vs Ruby on Rails article

Another Laravel vs Ruby on Rails article

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.