I know PHP and Ruby.

Using a PHP Rails clone (not out of choice), called Symfony, (which is apparently the best PHP framework), I notice that it's a clone of Rails. I think Symfony is stupid and that (SensioLabs is a clever business) because Rails already exists.

Apart from open-source projects gaining money, I don't understand why people are making Rails clones in PHP, when Rails already exists. Why not use Rails? Surely DHH coded Rails with Ruby for a reason.

Using Symfony, I notice that something doesn't quite feel right but I don't know what it is. I learnt Rails through a crap Sitepoint ebook and forgot it, so now I'm learning it through the PragProg ebook and I love that ebook. I don't fully know Rails, but I understand how it works (thanks to Symfony). I would love finish getting through the whole ebook so I can make 2 Rails apps. I remember Rails being more fun than Symfony using the Sitepoint ebook that I couldn't finish, and that had nothing to do with Ruby's pretty syntax.

  1. Why is Rails coded in Ruby?
  2. What is it about PHP Rails clones, that don't feel right?
  3. What is it that Rails is doing, that Rails clones aren't doing?
  • 4
    Ruby is the secret sauce of Rails.
    – Chiron
    Aug 7, 2011 at 13:45
  • 4
    Meh, I can't see something called Ruby on Rails being implemented in PHP. Aug 7, 2011 at 15:27
  • 2
    If memory serves, I heard a podcast once where DHH described he picked Ruby. I think it was this episode of This Developer's Life.
    – Adam Lear
    Aug 7, 2011 at 15:30
  • 2
    @Chris G - I find that incredibly hard to believe. The gulf between the underlying languages is massive- Ruby is a clever and comprehensively thought through programming language, PHP is a hack piled on other hacks with a bunch of Ruby features hacked in late in the game. PHP is easy to host and performs better, but if those had been DHH's priorities he would probably not have chosen Ruby back when he did. PHP was never really designed to be a programming language and people who care about language theory/CS tend not to be keen on it as a result.
    – glenatron
    Oct 7, 2011 at 14:57
  • 2
    @Glenatron None of that stops any intelligent PHP user from writing beautiful, expressive, modern web applications utilizing key "Rails" features like ORM. The idea that closures were only recently added to PHP is not going to stop anyone from using them!
    – Chris G.
    Oct 7, 2011 at 15:15

4 Answers 4


1.) Why is Rails coded in Ruby?

Rails was originally extracted from DHH's work on Basecamp, which was written in Ruby. Over time, the Rails core developers continued to extract and develop more features into Rails, and it eventually became a full-fledged framework.

Since Ruby grew in power and expressiveness over the years, it continued to be a good fit for the framework, so it's also continued to be the language that it's written in. (Plus, "C# on Rails" or "Java on Rails" doesn't have that nice alliteration.)

2.) What is it about PHP Rails clones, that don't feel right?

This can't really be answered objectively, but it's probably because of #1. The behavior and internals of Rails take advantage of many features that exist in Ruby and would be hard to replicate precisely elsewhere. For example, PHP doesn't have metaclasses, which Rails depends heavily on.

Apart from open-source projects gaining money, I don't understand why people are making Rails clones in PHP, when Rails already exists. Why not use Rails? Surely DHH coded Rails with Ruby for a reason.

Because not everyone has the time, budget, or inclination to learn a new language just so that they can learn a new framework.

By way of analogy, if it turned out that Brainfuck had a very popular web framework, does that mean you should abandon your clients who haven't written their applications in Brainfuck? That's no way to run a business.

I know PHP and Ruby.

Statements like "I know both PHP and Ruby" suggest that you may not yet fully appreciate the depth, richness, and idiosyncracies of either.

  • (Reproduced from stackoverflow.com/questions/6972992/… for posterity.) Aug 7, 2011 at 13:31
  • I believe an initial attempt at Basecamp was attempted in PHP, and wasn't working out to DHH's satisfaction. Hence, Rails was coded in Ruby.
    – Bryan M.
    Aug 7, 2011 at 15:15
  • 3
    +1 - there's a time an place to learn a new language - an immediate project of any importance is not one of the.
    – JeffO
    Aug 7, 2011 at 19:40
  • PHP does not have metaclasses out of the box, you are correct. However, since PHP 5.3 it is possible to implement metaclass functionality.
    – Chris G.
    Oct 7, 2011 at 12:27

1. Why is Rails coded in Ruby?

There once was the decision to program it in ruby. This design decision lasts until today.

2. What is it about PHP Rails clones, that don't feel right?

It's a feeling you have, hard to say on a wesbite like this one. You might want to ask a person that is more intimate with you and knows more about your feelings or even shares them.

3. What is it that Rails is doing, that Rails clones aren't doing?

An exact clone of Rails does per definition everything that Rails does. So this most likely will depend how exactly a clone was done. The different parts will result in different behavior. For example for a translation into another language, the other language might not have language features Rails on Ruby is making use of, which will most likely result in differences in design and then in behavior.


Why is Rails coded in Ruby?

Ruby allows a lot a meta-programming, and its permissive syntax allows you to create nice APIs that don't look like method calls at all.

For example, ActiveRecord, Rail's Object Relational Mapper, does both of these things well. First, it uses Ruby's meta-programming ability to create methods on the fly corresponding to field names in the database.

Secondly, ActiveRecord lets you declare associations to objects: a Person might has_many :books. That has_many looks like a declaration, but it's actually a method call. (Ruby reads this as has_many(:books).

Ruby also has a goal to make experienced programmer's lives easier.

Ruby makes these thing easy, so people do them. Other languages make these harder, or magic things like this are explicitly not part of the culture. Django, the Python mega-framework, has much less meta magic because it's not as easy in Python, and Python as a language leans towards "explicit is better than implicit". (I don't know much about PHP culture or the web frameworks on that side.)

I think these are some of the reasons DHH fell in love with Ruby, and he uses these language features with power in Rails.

  • It's all very well using the console to do some scaffolding in Rails, but such features exist in Symfony. Can you point me to where I can find evidence of how Ruby's language caters for meta-programming? Shouldn't classes suffice?
    – desbest
    Aug 7, 2011 at 15:54
  • 1
    The Pragmatic Programmers have a book: Metaprogramming in Ruby, which - in addition to being an introduction to Metaprogramming in Ruby - also spends about 50 pages talking about metaprogramming in Rails. I don't think simply classes are enough: for example, sometimes metaprogramming happens via method chain ("when you call this function, instead call my version of the function - which may or may not call the original"). This is a metaprogramming pattern in Ruby (which Rails clean up and makes easier to use)
    – RyanWilcox
    Aug 7, 2011 at 16:59
  • I'll have to read that once I've mastered Rails. It all sounds confusing.
    – desbest
    Aug 7, 2011 at 17:28
  • I'd just like to mention that PHP has ORM solutions too. It's not something that is exclusive to Ruby.
    – Chris G.
    Oct 7, 2011 at 12:26
  • 1
    There is a PHP implementation of ActiveRecord called phpActiveRecord. It uses all of these things. However, back when DHH built Rails, PHP was a long way from being able to do that. Mar 24, 2013 at 7:22

Why not use rails?

I'll offer some perspective as a user of both. I hobby program in Ruby/Rails and I use PHP exclusively at work. (Note: I do not dismiss Ruby/Rails as a hobbyist environment, this is just how I choose to use it.)

Many people treat Ruby/Rails as the holy grail of website development because of the popularity bandwagon and because its 'different.' In many ways it certainly is but not enough to dismiss PHP as something ancient.

Symfony doesn't feel like Rails because PHP does lack some of the syntactic sugar that rails provides. PHP is improving in this regard and 5.3's addition of closures has made a difference in how many of us write code.

Don't get me wrong, I love Ruby and I love Rails. But when you don't want to deal with complex or expensive website hosting or worry about performance or being 'bleeding edge', PHP is still extremely relevant today and it's frameworks are also very good.

  • Redbean offers great ORM functionality with PHP. So does Doctrine, Idiorm/Paris, and Propel.
  • Symfony2 and CakePHP offer a bloated web development framework similar in spirit to Rails.
  • CodeIgniter offers a full framework solution without the bloat.
  • Slim offers a sinatra-like framework.

Your insinuation that PHP rails clones don't 'feel right' is misguided I think, because they aren't clones and they aren't going to be the same as Rails. Learn to bask in the simplicity and familiarity of a PHP solution.

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