CakePHP vs Rails – Comparing Development EnvironmentsAuthor: Jay Brodie | Filed under: Ruby on Rails
In my previous (and very popular) post titled PHP vs Ruby on Rails, I wrote about the differences and similarities between the two languages. As I said in that article however, the comparison isn’t fair since PHP is a language, and Ruby on Rails is a framework.
For a proper comparison of PHP and Ruby on Rails, we need to look at comparing CakePHP and Rails, both MVC Architectures for Rapid Application Development (RAD). These tools allow developers to be able to generate baseline code and to be able to develop quickly within their architectures.
There are many benefits to using MVC, including:
- clean separation of logic from views
- REST friendly URLS
- maintains a stateless nature
- ease of control over rendered HTML
- use of Test Driven Development (TDD)
Compared to my previous post, this is an apples-to-apples comparison between CakePHP and Rails environments.
Development between CakePHP and Rails is similar yet very different. Both are MVC architectures which in itself make development simpler. Both have generators to allow for fast code development. There are however some key differences between these two architectures.
Scaffolding is supported by both architectures and they both have a specific look that can be customized.
The local development support for Rails is ASTOUNDINGLY better than CakePHP.
For CakePHP to run on your local environment for development, you need to have some sort of web server (Apache, IIS) running locally with PHP installed as well as a rewrite module running. Once this is in place and you have your code base up and running within the host, you can then start your development. Rails, on the other hand, requires only a simple command line to fire up a local server and get working. This is without a doubt one of the BEST things about Rails development.
Another big win with Rails is migrations. These allow you to be able to interact with your database and make structure / data changes through scripts with ease. The mechanism makes sure you are up to date and can sync your database with a couple of keystrokes. This is greatly beneficial when you are promoting code to a production environment as you can simply run your migrations and update the database on a remote host to be versioned to the same as your local database.
CakePHP and Rails both have testing environments. There are several for Rails but the preferred testing environment for Rails is rSpec. PHP also supports testing; although I have not spent a ton of time working through it, I do still prefer rSpec and Guard.
Capistrano is a deployment tool that is primarily used for Rails deployments. It has been adapted and extended to be used for deploying other projects including CakePHP. There are many different 3rd party extensions for use with Capistrano that will work with a gambit of different languages.
PHP in general has a massive community that outweighs the Ruby side. However, when comparing the community and documentation between the two frameworks, Rails has MUCH better documentation than CakePHP. There are a large variety of sites out there with Rails documentation that contain up to date, and in-depth answers. CakePHP’s documentation on the other hand, is scarce and vague.
Without a doubt, the winner of the MVC framework conversation is Rails. It is sleek and clean, functional and productive. There are many points in Rails that CakePHP would benefit from adopting to continue its growth in the market share.
The PHP vs Ruby on Rails argument isn’t a simple one, and judging by the popularity of my previous post on it, the argument is a hot topic. The biggest thing with selecting a development language is to factor in everything. You need to be able to look at the raw development costs of your developers, your hard costs of hardware or hosting for your applications, and of course the cost of maintenance for your application throughout its life cycle.
PHP programmers are easier to find than Ruby on Rails programmers, hosting will be cheaper due to the fact that PHP as a language is more supported on hosting providers.
The cost of maintaining either system is pretty much a wash, as either system will have some sort of long term maintenance.
A definitive call on which system is right for the job is probably best summed up like this:
Use the right tool for the job.
If you are working in a larger scale corporate environment and you have the option to host and maintain your own server, then I would by all means recommend using Rails (Ruby on Rails) for your solutions.
If you are a home-based business, or a weekend programming warrior doing odd jobs, then the solution for you would be CakePHP due to the easy availability and lower costs of PHP hosting.