I consider myself a programming polyglot. I am proficient in five to seven languages and am competent in many more. Consequently, like many programming polyglots, I am a bit of a snob. PHP programmers tend to be unilingual or bilingual (Javascript). They are unenlightened. If you asked the average PHP programmer to explain a closure, they would probably express bewilderment. Brutes! Like I said, I am a bit of a snob (and the preceding text was satirical…mostly).
As is the case with much snobbery, this is ill-advised. Prior to PHP, I remember writing applications through CGI, mod_perl, or full-blow C extensions to Apache httpd. It was not very productive. Enter, PHP. From the beginning, PHP was designed as a template language to make web development easy. As such, additions to the language and its tool set were evaluated against a fitness function that emphasized ease of use and productivity for web development. At the time, it was the strongest solution to a problem of increasing prevalence.
Fast forward a few years. I had been out of the web development scene completely when a bout of temporary insanity inspired me to attempt building an online dating site (thanks, Markus Frind). Since I used Ruby extensively for non-webdev, Rails was my obvious framework choice.
Does Rails have advantages that cannot be replicated in PHP? Of course! The most glaring advantage of Rails over PHP is the fact that PHP is not Ruby. Ruby is lovely language. Seriously. Ruby allows you to think in code. It is incredibly productive. You can take very complex abstractions and implement them in Ruby with ease. However, web development is not very complex. Most web development is CRUD. Sure, Ruby might be slow (although 1.9 is looking nice) but most applications really do not require high performance. And when scalability does become an issue, Rails is rarely the bottleneck.
Do I miss ruby gems? Sure, but Pear works. Moreover, integration with PHP is often easier than it is with rails. When was the last time you noticed that popular api or library lacked a PHP interface? Most sites release official PHP libraries (s3, ec2, facebook, gdata, …)
Conversely, PHP has one several advantages over Rails. Most notably, immediacy. Deployment via SCP is very satisfying. Moreover, PHP now has many rapid-development frameworks that employ MVC and active record patterns (e.g. CakePHP). While you don’t have the elegant sexiness of Ruby, you have almost everything else.
Do PHP programmers tend to be weak programmers who produce mediocre code? Maybe. If so, it can probably be attributed to the law of large numbers. There is a virtual army of PHP programmers; there are very few DHHs. For large-scale, very complex problems it may be better to use a language that naturally excludes poor to mediocre programmers, but this is not true for web development. Besides, there is no shortage of criticisms of the rails community.
Finally, there is nothing to stop you from using PHP for the CRUD front-end and Ruby or some other language to do more complex heavy lifting (e.g. spidering, categorization, etc). It seems to have worked well for facebook.
echo "Hello, Old Friend";
UPDATE(OCT-27-2009 @ 1:39)
I mentioned below and repeated in the comments section that I have used
Capistrano (a site which, given the current context, ironically uses PHP) and
Passenger, but, for reasons I could not qualify, I thought PHP was simpler. Mark just helped finalize the thought for me: PHP is usually preinstalled and ready for rapid deployment — i.e. immediate initial deployment.
Heroku is wonderful, but not every hosting service is Heroku. If you want an application with diverse end-users, PHP is more likely to be eligible for simplistic initial deployment. It may seem like a minor issue, but in my experience, it is not.
END_UPDATE
This post was motivated by an open-source project I am currently coding. It is not yet released but for the purposes of this footnote, pretend it will have a deployment pattern similar to Wordpress. I started writing it in Rails. However, after speaking with several people who will be end-users, I realized that the most important factor would be ease of deployment. While Phusion is a game-changer for deploying Rails applications, I think PHP is still easier for most web developers.
Also, for the sake of disclosure, I should make it clear that I am not an expert web developer. As you might notice from this blog, most of my work is in complex systems. Most of my time is spent writing code in C or C++ with Ruby acting as glue.