PHP vs. Ruby on Rails: The Million Dollar Question

April 15th, 2010 Leave a comment 57 comments
Like the article?
PHP vs Ruby on Rails

PHP and Ruby on Rails both have their very dedicated followers. These followers are so passionate about their chosen platform that gathering good information on the differences between the two can be pretty difficult. Yet this information is vital if you’re going to make a decision on which platform to develop your next project. Here’s a quick look at some of the core features and differences and some additional factors to consider when choosing PHP or Ruby on Rails.

PHP is a Language

Comparing Ruby on Rails to PHP is unfair. PHP is simply a programming language. However, it is an extremely flexible and useful language. PHP uses very little memory and performs quite well. It is also a mature language with a wide variety of extensions and library modules. Originally developed as a scripting language to be used in HTML pages, PHP has gradually matured and now includes full object oriented features. The later add-on of object oriented features is one of the biggest criticisms of PHP. Some programmers feel that PHP encourages sloppy coding because of its script-like roots and lack of a clear object oriented strategy from the beginning.

PHP, as a language, does not have all the features of Ruby on Rails. As a result, coding a site from the beginning in PHP requires a great deal more development effort since things like database connectivity must be coded from scratch. However, there are a number of mature and stable frameworks written in PHP that provide features similar to Ruby on Rails. This is one of PHP’s strong points — choice. The developer can choose the framework with only the features needed or develop the needed features himself. In working with Ruby on Rails, you are stuck with the features provided. This can sometimes make for a difficult development effort when the framework’s ideas about how an application should be configured do not match the requirements of the application. It can also cause performance problems when the framework takes more overhead than needed for unused features.

Ruby on Rails is a Framework

On the other hand, Ruby on Rails is a framework developed in the Ruby programming language. Ruby was designed from the ground up with object oriented design in mind. It has a very tight and clear syntax and programming in it can be down right elegant. It can also be extremely inflexible. As a programming language, Ruby often runs more slowly than PHP and requires more memory. Rails is a framework that provides a number of features that are useful for the rapid development of web applications. As a framework, Rails provides some great features. It supports the ActiveRecord design that maps database records to objects. ActiveRecord hides a lot of SQL code from the developer by handling a lot of the mundane tasks of creating, retrieving, updating and deleting objects automatic. Rails also includes a routing system to made URLs to methods and a templating system for generating HTML output. There are numerous other features including sessions. These features make it easy to build a web application on Rails.

Rails list of great features, is also part of its drawback. As a developer you lose a lot of control over the SQL queries in your application with Rails. You also use overhead to run features and services that your application may not need.

Other Considerations

PHP and Ruby on Rails are about equal in terms of how easily or how difficult they scale to meet growing demands. On the spectrum of scaling they both benefit from increased memory and CPU but when an application requires load balancing or being served from distributed servers, the complexity grows. They both have similar requirements in terms of scaling and face similar challenges.

In the past, Ruby on Rails required more work to deploy but the modern situation is much easier. A new enterprise deployment system has made Ruby on Rails as easy to deploy as PHP.

The bigger consideration should be the development teams comfort with each. If you know PHP well and have worked with it for some time, learning Ruby will be a stumbling block. It makes no sense in terms of developer efficiency to use a new language or framework simply because there may be some minor gains. All of the features of the Ruby on Rails framework are available in PHP frameworks or can be developed using PHP. Developers should not be required to work in Ruby simply to gain access to some framework features. Developers write the best code in the languages that they know well.

Another important consideration is the rest of your platform. If you are using a large amount of PHP in other ways such as ad servers, modules or other add on components of your web site, it may make sense to continue to work with PHP. You should never underestimate the value of being able to integrate existing PHP code into your future work. Tighter integration is generally desirable in a web application. The platform that the bulk of your code is developed upon will likely guide you towards what platform you should use for your other development efforts.

And the Winner Is?

The clear winner is the platform that you already know, that will do what you need and that your clients need. In most cases, it is going to be PHP for a number of simple reasons. First of all, most web hosts support it so there are a lot more clients using it. You will find more jobs, more web hosts and more opportunities to use PHP. Secondly, the features that Rails as a framework provide, can easily be duplicated by using one of the many excellent PHP frameworks. CakePHP, in particular, supplies many of the same features. You probably already know PHP. Your existing knowledge can not be overvalued. Experience with a platform means that you already know all the pitfalls and gotchas of working with it. Finally, PHP is more flexible. If you don’t need a full framework, you can roll your own in PHP. If you need your application to work differently than what the framework defines, you can do that in PHP. And chances are you can find a library or extension to do anything you need to in PHP. While Ruby on Rails has some great features, the market has already declared the winner to be PHP.

Help us spread the word!
  • Twitter
  • Facebook
  • LinkedIn
  • Pinterest
  • Delicious
  • DZone
  • Reddit
  • Sphinn
  • StumbleUpon
  • Google Plus
  • RSS
  • Email
  • Print
Don't miss another post! Receive updates via email!


  1. Jagan says:

    It seems you have declared php to be a winner but not the market!

    There are increaing jobs for RoR developers.
    Many medium hosting providers are also able to provider hosting solutions for RoR for a very affordable price.

  2. david says:

    I agree. If you are not a sloppy programmer and you take advantage of php oop patterns and framework you can develop quite a clean and efficient platform.

    I’ve develop core classes that i can keep on recycling throughout any new website development.

    and i love the fact that there are all customize and it does exactly what i want it to do and i can use them as i please.

    I always hated framework because of the overhead.. I hate the fact that there are things memory is loading and taking up server resources when it is not being used.

    For me ,.. this makes absolutely no sense.

  3. joeromano says:

    Yup! ruby on rails is wasting memory… too bad 🙁 php can do what ruby rails can do so why shift to rails?

    • Ryan says:

      I’m glad you morons all flock to PHP. You keep the trash out of the communities of real languages and keep our wages high while driving your own down. I would NEVER employ a PHP developer for a serious project. Merely by using PHP he has already demonstrated his incompetence.

      • Thorpe says:

        Wow that’s harsh!

        I’d hire a developer who has worked with both of them and knows the weaknesses and strengths of both.

      • Yep says:

        Agreed. PHP is weaksauce.

      • Sid says:

        Lol, and Ruby is the so-called real language? Try C#, Objective-C or Java instead. Let’s remember that idiots like you using ORMs like ActiveRecord instead of learning proper SQL and indexing, allowed a major involution to happen.

        Programming languages like C/C++ or even PHP for that matter will not spoon feed you, so it is up to you to develop a good architecture and application. In either case, Ruby and PHP are only useful for startups or semi-functional prototypes. After that you have to hire real programmers to deal with high loads, async and concurrency, something that is way past beyond the understanding of your average Ruby developer.

  4. rubyist says:

    I think the problem is not been ruby or in this case, ROR and PHP. PHP has a larger following and it is an easy language to learn for beginners who have little formal training. Ruby is a more complex language though syntax is a magnitude better than most languages. PHP has added OO concepts to the code base but few use them. PHP has more libraries but most are incompatible and some are horribly poor in quality. Ruby is OO from the ground up. The libraries are fewer but more encompassing of best practices, community accepted idioms, and of higher quality. Meta-programming in PHP is a nightmare. Ruby is baked in. Rails is a framework that solves most large web problems. Sinatra is good for smaller apps. Rack, Metal, Unicorn, and Merb were created to look at the middle layer and are complex frameworks/server technologies that integrate with rails perfectly. It is unfathomable to consider migrating joomla to wordpress or even integrating them.

    PHP solves most problems. Ruby solves most problems. But come on guys, ruby is a better language. It will kill php over time.

    • “It will kill php over time.”

      This statement is laughable.

    • Sid says:

      Both Ruby and PHP are being replaced with Node.js as far as the quick and dirty approach goes. So wishing for the demise of PHP will see the demise of Ruby as well, since they are pretty much the same non-asynchronous crap.

      Large and critical projects like banks will still done in the usual corporate Java/Oracle/MSFT stack.

  5. ahseng says:

    because of hearing how ROR is powerful of… i started to try on it…. unfortunately the setup is nightmare…. lack of tutorials… bunch of ROR tutorial is out of date..and take me 1 day and not even to display a “hello world” It is really hard for a noob beginner like me…. but php just take me few hours to make a simple login system… so ROR is suck for newbie

  6. dank says:

    @rubyist, I completely agree. RoR is far more fun to use.

    @ahseng, RoR has really been evolving over the last few years, and a lot of what’s online has become outdated. I picked up a rails 3 book at my bookstore, and that was really all I needed to get started. Once you learn the basics, most everything makes sense.

  7. Nila says:

    if i can get what i want with PHP, why should i bother myself with RoR?I guess i will try RoR if i come across something which can not be accomplished by PHP but RoR… as for now, PHP rocks….

  8. ceekays says:

    I am a fan of both PHP and RoR, I wouldn’t say I love RoR but his arguments are unfair and unfavourable, I cant buy them even for a single penny!!!!!!

    Before we argue, let get it right that RoR is NOT A LANGUAGE but a framework. It sounds that the author noted this but did it the savagery way and continued to argue like that.

    If to compare, let’s take “RoR” versus similar PHP frameworks (such as Symfony, Achievo, PHPOnTrax, CakePHP, and Mojavi). Otherwise, Take Ruby( the language) and PHP.

    Then, we can talk the other things later!!

  9. Anonymous says:

    “Finally, PHP is more flexible. If you don’t need a full framework, you can roll your own in PHP.” Why can’t I roll my own framework in Ruby?

  10. Steven says:

    BTW, ruby also can be run used via jruby which allows you to deploy your Rails application under any Java container. Not to mention you can use any java library in your ruby code. In my opinion having access to the vast array of Java APIs using ruby’s simply syntax is a huge win for ruby/RoR.

  11. Andrew says:

    anything done in ruby can be done in php and vise versa..iv toyed with ruby and rails and im muc more happier with php things are simpler to do, file uploading etc. ruby requires too many add ons to achieve a simple task..
    i know this because i made an application with ruby on rails and the same app in php..
    ruby has better syntax and is neater and the routing is much better than any php framework..
    for those looking to learn mvc, learn RoR instead of asking questions on what MVC is, RoR will teach it best..and you can use what u learnt in php..
    when it comes to deploying php is much easier, ruby gets complicated on that part..
    However, i do agree “PHP is more flexible”, this is true, rolling your own framework is much easier than doing it in ruby.. in PHP it will be easier to get it right, while in Ruby the chances are when ur rolling ur own framework it will never be as good as Rails..thats why everyone uses Rails in Ruby, and in PHP you have ur choice, Zend, CodeIgniter, Cake, Symfony etc.. or your own which could come close to the PHP frameworks which are already there..
    PHP is much easier to learn and get it right than Ruby..
    All the Rubyists disagreeing you should first get into PHP and vice versa, then youll know..

    P.S. I develop in Ruby, RoR and PHP etc.

  12. joe says:

    Your argument seems to amount to “people know PHP already so they may as well stay with it hence PHP wins”. Interesting…. but how do you square this up with the fact that we aren’t writing it all in assembler or COBOL?

    • Michael Dorf says:

      Joe, your argument is fair except that “we aren’t writing it all in assembler or COBOL” doesn’t quite apply to PHP. Is PHP “old goods”? Absolutely! Is it going away anytime soon? Absolutely not! But it does save you plenty of time and headache using a language that you are already comfortable with and that is well supported in the industry.

  13. Samuel says:

    Well, actually we can’t compare PHP and Ruby as languages. PHP is actually a DSL for web scripting. Ruby is general purpose programming language. PHP relies on thousands of C functions, callable from PHP. In some aspects it is good, because well written C function is really fast. But from language design viewpoint it is nightmare. Core PHP is basically frontend to thousands of C functions with few language constructs. Ruby on the other hand is mainly written in … Ruby. Only small bootstrappable part of Ruby language is “frontend to C functions”. Most of Ruby OO system is written in Ruby itself. It is a design choice from ground up. It also has very powerful reflection- and metaprogramming capabilities. So, we really can’t compare these two languages. They are targeted to different people and their purpose is different.

  14. rubynubie says:

    Being an expert in either language/platform will allow you to write a great system. Context is clearly missing from these comparisons. Both systems are highly complex and mature products and need a series of articles to even begin to compare using real world scenarios.

    Personally I like Ruby as a language, its fun, and with discipline allows you to write very good code. I never liked PHP, the language just didn’t click.

    The point, comparisons like these are always personal…

  15. php boy says:

    I totally agree with the author.

    Programming in Ruby is like programming in Perl. It’s nice on the resume but it adds no traction.

    The people we hire either know or are taught design patterns. Going ROR for that reason is a dumb mistake. It will cost you more on payroll, and total development costs will be higher.

    Most new recruits have java or c# knowledge. It’s about staying mainstream. Programmers can learn php in a couple days when they know java or C#. Tutorials are all over the web. Recruits are more autonomous. From an employer’s perspective, it’s more desirable.

    Saying PHP leads to unreliable code because PHP is a lousy engine is dumb. The programmers is free to use all standard coding practices to implement whatever fits the situation best.

    Software Engineering 101 guys ——

  16. John Adrian says:

    ruby focuses on human than machine so that’s why it is slow.

  17. hrishikesh says:

    In my experience with ruby (on rails), it is extremely fun and friendly to work with. However, the larger issue is quality resources are not available in Ruby. Ruby language is like driving a Ferrari and if you do not have equally good developer, it can be a nightmare. On the other hand, PHP seems to be a little lenient language which is easy to use and understand. I have loved ruby but in all practicality, I would use PHP for my next project.

  18. cm says:

    We wrote a large web app for medical offices using PHP. I’m in the process of rewriting the whole system in RoR. What a breath of fresh air RoR is. PHP is horrific for any large scale app. I understand large scale is relative. Our medical app is right at 500k lines of code. With PHP it has become so bad that any minor change is hours of code changes and debugging. Maybe cakePHP or another framework based off PHP would have made life easier, but pure PHP for a large app is a bad experience. Using Rails, I’m developing at a pace I’ve never developed before with PHP. RoR is difficult to start out with because it does so much behind the scenes that an inquisitive mind will have a hard time with the what-if’s. If you are experienced with PHP (or web-app developer from any discipline) RoR has a bit of a learning curve, but is very simple to get going with. Make the jump, dump php…you’ll thank yourself later.

    • Rollins says:

      It’s funny you should say this; considering that Facebook, one of the largest apps in the world, is written almost entirely in PHP.

      • marcc says:

        Facebook’s front end is PHP code translated to C++ source, itself compiled using g++. Facebook’s back end is written in a variety of languages including Java, Perl, etc.
        Saying that Facebook is written in PHP is as misleading as saying that Twitter is written in Ruby/RubyOnRails.

  19. doms says:

    @cm you are correct. You shoudn’t have used raw php. You should have used a php framework. RoR is a Ruby Framework so you should not compare php with RoR.

  20. Ares says:

    @cm You can not evaluate/compare a language based on the skill of the developers who built the web app you are talking about. Did you used oop? Was the system well designed? Where software patterns used where appropriately?

    I don’t see why a good designed and thought web app using php will make minor changes require “hours of code changes and debugging”.

    So I think you are going with the wrong assumption of comparing a framework RoR, which employs good design and software patterns with a programming language on its own.

  21. rocky125 says:

    I use both php and ruby on rails and i like both. both are very powerful on server side. however, i think we can’t do something like ajax using php but on rails we can. not sure if im entirely correct.

    • zaraki says:

      You are wrong. Ajax can be used with PHP. Advanced Javascript and XML..If you know PHP then you also know that you can use Javascript and XML within. There are many books relating to this.

  22. ryan says:

    I think Rails is superior because it’s culture is superior. PHP is full of noobs who write terrible code (I”ve done PHP professionally for years) and it is a nightmare cleaning up after most people’s mess. Sure, you can write clean PHP code, but unless you’re the lead developer on a greenfield project, good luck. If it’s an existing system, you’ll be refactoring for years just to do any little thing.

    The Rails community is test driven, up-to-date with the latest technologies (git, coffeescript, etc) and they’re consistent with best practices and so tend to produce products of far greater quality and malleability.

    I’m so sick of PHP that I have been spending the time to learn ruby and rails so I can hopefully get out of this nightmare of a ‘career’ and be around smart people who actually care about programming!

    • zaraki says:

      You mentioned about programming. If you consider PHP, it would be the actual programming. Ruby on rails is so basic and can only do so far but with PHP , you actually can do more ( my opinion ). Let me tell you the reason, you can develop the PHP client with C headers and I believe you will not stand up and tell me that C is not a capable language since it is considered one of the most powerful. The actual ( real ) PHP developers do not work on just the PHP / Website but also do work with the headers and C side.

      • marcc says:

        If you knew Ruby just a bit, you’d know that it’s easy to write C extensions to Ruby code (Ruby itself was originally written in C). I use C with Ruby all the time, in particular for functions that require high performance (which Ruby is not always very good at).

    • dman says:

      I am fairly new to coding, studied it a lot, used PHP with WordPress for a while and liked it. Just started with RoR, Spreecommerce, tuff to start but very structured. WordPress is awesome, but I have to start learning RoR because it is so much cleaner and structured, PHP just has no true structure, even in the WordPress source code.

  23. Willie says:

    Take a look at Facebook with 500 million active users. What do they use? Think performance is important to them?

    • marcc says:

      Yeah, Facebook’s front end maybe PHP code, but it’s translated to C++, itself compiled using g++. So Facebook’s responsiveness is not due to PHP, it’s due to C++. Please do some homework on this…

  24. Richard says:

    This comment comes a year and a half after the original post, so please take that into consideration. I work with a propritary, web based program that was developed for the sole use by my company. It’s basically a web interface to the underlying MSSQL database and uses RoR.

    While I love the ease of RoR, I’m also discovering it’s pitfalls. For one, RoR and MSSQL do not scale at the same rate. The application often falls into a “zombie state” and becomes unusable as a result o the framework’s forced internal mechanisms. It’s also extreamly slow. For a mid-sized, flexable company, in a real-world situation, this is unacceptable.

    On the other hand, PHP is much more complex in terms of rapid development. Changing a few lines of RoR is the equivilent of changing whole functions in PHP. RoR’s “conventions” make development simple and the language itself is easy to read and understand after only a few weeks of study.

    The bottom line? For smaller applications and/or where speed is not an issue, RoR wins hands down! But, for applications that may havehundreds of users accesing the database simultaniously and continuously — PHP looks like the way to go.

    One other thing that’s developed since this blog was written: RoR is starting to fall out of favor with some major development systems. Of note, NetBeans no longer supports RoR as of the latest version.

    • piousbox says:

      @Richard Netbeans supports RoR as a plugin. I use Netbeans to write my Ruby. That this functionality does not come shipped with netbeans core doesn’t mean that it falls into disfavor. Rather, I think they are trying to clean up the core. I believe nothing beyond Java SE should be at Netbeans core, and pretty much everything should be a plugin.

      • marcc says:

        Exactly! In addition, RubyMine (from the JetBrains folks that gave us IntelliJ) is a great Ruby/RoR IDE. There are other environments that you can use to develop Ruby/RoR, for example TextMate on the Mac, or, in my case, Emacs on Linux.

  25. jcho360 says:

    I have not to many years of experience, for me ror is more fun,both language are great, even if you use any php framework…

  26. dman says:

    Check out Heroku and Engineyard, 1 and 1 too for Ruby apps hosting. Git is great too.

  27. piousbox says:

    This article is misleading. From the beginning you compare PHP to RoR – but how about comparing PHP to Ruby, and CakePHP to Rails? That would make more sense. Also, you say that PHP is as scalable as Ruby. That is not true; Ruby is more scalable. As for market, maybe there are more PHP jobs but Ruby jobs pay more. Finally, when you say that existing knowledge cannot be overvalued and that what you already know is more valuable than what you don’t know – I have to disagree. It was somewhat painful for me to switch from PHP to Ruby, but the benefit I gained is well worth the effort. Overall, I think Ruby is a clear winner over PHP.

  28. Azhar Kamar says:

    Great in-depth article. I’ve always wondered what exactly Ruby on Rails was. Well i’ll just stick to PHP.

  29. yonab says:

    I think RoR is the best and it is succinct language .PHP is a sloppy language.

  30. Alex says:

    Apart from what has been said, here is a bit of a more unique perspective from my side. I had a Java and C background from university, but was working in a non-coding job for several years before going back to being a developer. I had some, although little, knowledge of PhP and no knowledge of Rails nor Ruby.

    That was in 2008 and due to a colleague of mine I went the RoR route. It was great and still is, but there are drawbacks. At least in Europe the number of good RoR developers is minimal, while the number of people with an agreeable knowledge of PhP (although very often without any knowledge of PhP frameworks) is much higher.

    So, my advice for everyone would be to look at your ambitions realistically. If you are in Silicon Valley and are working on your 1:100 shot to build a viable business, go RoR of course. You are likely smart, can find very capable colleagues and are working with cutting edge stuff.

    However, if you are sitting in Boston or Amsterdam or Moscow and you are doing smaller apps or a lot of smaller projects for clients, PhP is definitely the way to go. Just because you can find people, yes they may suck with their current skills, but at least you can use them right away and they might get better.

    Anyway, we will stick with RoR, but that has to do with what we are working at.

  31. Jesse says:

    I am glad i stopped by here to notice that Rails is a framework. It makes it disappointing. The problem with a framework is that it tries to cover all bases to make everyone happy, when in reality I would only use the one or two things. What is wrong with opening notepad and typing in, hitting save and seeing it instantly. Watching a video about Rails (someone making a blog in 20 minutes) makes it seem very confusing. As a programmer, I started out learning PHP and I find it to be rather nice, neat and effective. I understand that Ruby jobs pay more, that’s just because as you stated, there are less Ruby Devs. I find PHP to be extremely, and have yet to find something I cannot do yet. With ease, I have installed PHP on hundreds of computers and varying operating systems, it is always a super easy task. Hey, maybe I have to type an extra word or two, but I feel like I have more control over what is going on in my database than what I have read about Rails.

    I am sure some people use Rails, just to use it so they can say, “PHP? Ha, thats old school!” as someone said to me. After doing some massive research today about Rails, I have decided to stick with PHP and Javascript. Thanks for the original post and the comments that followed. I am sure even if I was in Silicon Valley, I would not try and waste valuable programming time, learning Ruby, that actually sounds like it could be someones downfall listening to that advice buddy. As the article says, do what you know. If you don’t know any, do Ruby, apparently you will get paid more until everyone else starts doing it too, than the PHP guys will get paid more.

  32. PHP and ROR says:

    after reading this article i have concluded that php is winner… because it is most flexible scripting language. if you want RAD rather use PHP framework which have been already developed that are similar to ROR. SO PHP is really is last choice

  33. Dennis says:

    Declaring PHP a winner of RoR is simply one of choice. Both languages have their “quirks” and are both liked/disliked by the open source community. But for the simple fact that Ruby can run an extended process without having to be “kickstarted” is a winner in my book. The ability to also have really good kernal processing built-in when dealing with the language is also a reason to choose Ruby.

    Rails provides an extremely fast approach to developing an app, whereas PHP and its multitude of frameworks can provide the developer with daunting white screens of death with no reason whatsoever and many hours of debugging with no kind of stack trace.

    The quickness to market is a big plus in today’s economy and RoR provides that ability, especially with technologies such as Capistrano.

  34. Jeff says:

    So, as a freelance developer, I’d like to know which language pays better. Today, it seems that there are more PHP developers needed in the market than RoR developers. But I don’t real care about that so much.

    I would like to know which of these 2 skill-sets pays a better hourly rate.

  35. My fist language was PHP. Then, because I always want to learn I started to play with Ruby and RoR. After the first problems with understanding the deployment etc I was totally amazed both from Ruby and RoR. I think as a language Ruby is far more complex and better than PHP.

    Unfortunately at my job I need to use PHP these days so Ruby and RoR is just for home playing in the moment. When I faced with the issue I need to use PHP again at work I tried to find a RoR like framework in PHP and luckily I found the Yii. With the framework I am quite happy to code in PHP because it handles very well the relations, there is a good console script solution for background processes etc. So if someone wants to learn PHP I recommend after the basics of the language to try Yii.

  36. This is an argument that may never end. You are absolutely right about dedicated (i call it passionate) followers. You should stick with what you know whether that is PHP or Rails. For me, I learned Rails and I have no idea what PHP can or cannot do. The bottom line, though, is that Rails does what I need it to do. If it didn’t I might have looked at PHP.

    In all fairness though, the comparison should be Ruby vs PHP. Great article!!

  37. Kelsey says:

    Who cares, Node is the future.

    Stop living in the past people. PHP is out, better tools exist. Banks use COBOL or FORTRAN, but that doesn’t mean they’re happy about it. Same with PHP.