Top 5 Reasons PHP Developers Love Rails

As Mark mentioned in his latest post, most of our previous applications have been built with PHP (including Squidoo). Despite all our years of collective PHP experience, we made the decision to switch new development to Rails less than a year ago. In that time, we've hosted a training session, attended a conference, connected with other developers in the community, and even had one of our top developers selected to speak at this year's RailsConf. Admittedly, the switch wasn't altogether painless; but, as I look back on the past 7 months and how far we've come, I've made notes about everything that Rails provides that has made our lives easier. This isn't an exhaustive list (what did you expect?); but, it does cover the top 5 from across the Development Lab here at Viget:

  1. ActiveRecord – Obviously a critical component of the Rails framework and something that the PHP world still seems to be lacking. It's clear which ORM library you'll use when developing in Rails; but, there isn't a clear choice when developing in PHP. While the myriad PHP frameworks provide a multitude of choices, nothing is as developer-friendly as ActiveRecord.
  2. Test::Unit – Though we were new to Rails, we had been using Test-driven development practices even in our PHP applications. The framework that we developed in house pulled in SimpleTest to handle all our model and controller tests; but, the integration wasn't as nice as we would have liked. With Test::Unit and its integration into Rails, writing and running tests became both easier and faster. Through the use of fixtures and database transactions, we no longer felt the pain of writing mundane (and sometimes complex) set up and teardown methods for managing our test data.
  3. Mocking Libraries – When working in PHP, we found ourselves changing the behavior of our classes just to make them easier to test. Though SimpleTest did provide mocking capabilities, libraries like Mocha and FlexMock, combined with the power of Ruby, let us mock out method calls deep inside our code – something that just wasn't possible for us before the switch.
  4. Filters – I recently found myself maintaining an existing PHP application where I needed to add some complex permissions checking. While the task took quite a while, it would have been easily solved in Rails through the use of filters. The ability to remove duplication with before filters and clean up exception handling with around filters has been a huge productivity boost for us.
  5. Ruby – Last on the list – but it's truly the cornerstone of the framework. We did have some of the hurdles involved with learning a new language; but, the time we spent ramping up has been well worth it. The syntax of Ruby is much more elegant and consistent – something that PHP has been sorely lacking for a long time (I hear it's coming in PHP 6).

As we continue to push for using Rails for web application development, I feel confident that we're giving our clients the best solution possible while decreasing the time it takes to bring their products to market.

Patrick Reagan

Patrick is development director in Viget's Boulder, CO, office. He writes clean Ruby code and automates system infrastructure for clients such as Shure and Volunteers of America.

More articles by Patrick