Everyone is aware of the basic, significant differences between Ruby and PHP. If you consider the syntax, PHP requires semicolons at the end of lines and generally requires curly brackets to enclose blocks of code. Ruby, on the other hand, uses newline characters to denote the end of a line of code and many code constructs such as function definitions, and various loops are ended with the word “end” rather than being surrounded by curly braces. In Ruby, you don’t have to specify the return line as the return value of the last evaluated line is returned automatically. Over at RefreshinglyBlue is a detailed write-up on more differences between PHP 5 and Ruby. PHP also has more built-in functions than Ruby. The Rails framework has many helper methods for formatting dates, numbers, currency, and such. However, PHP has a vast library of functions that makes it a complete tool set for web application development.
Both PHP5 and Ruby have object oriented features but Ruby is more sophisticated in terms of OO constructs, the post notes. Both languages can do almost similar things and both have try/catch/throw style exception handling.
Coming to frameworks, the author says the Rails framework is 'fantastic' and makes developing web applications easier due to all of the built-in functionality, especially the ActiveRecord functionality. The built-in error handling with error_messages_for is also helpful, as are the plug-ins that allows you flexibility in displaying error messages. Different configuration files for live, testing, and development environments is also a neat option.
Although PHP has over 40 different frameworks available, CakePHP and Symfony are the most popular and both of them are Rails clones. The author prefers CodeIgniter, however, that follows the Model-View-Controller (MVC) model but is much more lightweight than Rails. "CodeIgniter has no code generators like Rails has. It does have an ActiveRecord style Database class but it is not as powerful as the ActiveRecord in Rails. It is, however, quite nice and very helpful – much better than nothing. CodeIgniter, as far as I know, does not have anything comparable to Migrations in Rails."
Next, PHP does not officially support namespaces and Ruby does. But PHP 5 has the ability to autoload classess that are undefined, which is a good workaround for PHP not having namespaces. With regards to documentation, the author says PHP kills Ruby and Rails when it comes to ease of finding, reading, and even generating documentation. The Rails documentation is comprehensive, but hard to navigate and has fewer code examples. PHPDocumentor produces better looking documentation that is easier to navigate than RDoc does. Coming to hosting, PHP is extremely easy to host, whereas Ruby on Rails is miserable in this department. For Ruby on Rails you need to have a virtual private server (VPS) or a dedicated server that can cost USD 50 per month.
So while PHP is a more elegant language and more powerful than Ruby, Rails is a very comprehensive and effective web development Framework and there’s nothing exactly like it in PHP. "Developing in Ruby on Rails is also a very fast process because Ruby is a very concise language requiring much less typing than any other language I’ve worked with."
The deciding factor then are the hosting issues. For small to medium sized projects, PHP is much easier to deploy, less expensive to host, and the language is capable of taking on everything those types of sites require. For larger businesses, who have the budget for their own VPS account, Ruby on Rails is a good option.




