Facebook Developers created a great hype in PHP World around their new Open Source project called HipHop for PHP only with one blog post: HipHop for PHP: Move Fast. I’m waiting for HipHop for PHP to become public available to try this great feature on few projects I work on.
Facebook Developers where very kind to mention some Open Source competitors that already publicly available for try and use. Two of them I’m interested in are: Roadsend and phc.
While waiting for the HipHop for PHP I decided to see how and what Roadsend and phc can do, what limitations they have and what features they provide. It wasn’t full-scale tests, just some quick tests.
Neither Roadsend nor phc were found in Ubuntu software repository, so I compiled them from the source. I was surprised by clear installation instructions provided by both PHP compilers. There was no trouble to compile and install Roadsend and phc, except dependencies that were easily compiled to (I just hate dependencies). Well, I should mention that phc requires much more time to compile event without counting PHP compilation time comparing to Roadsend.
First “Hello World!” PHP script was compiled without any trouble. Script that gathers 100 records from MySQL database compiled well also. I haven’t tried anything complicated yet, but I don’t need it for now. I want just to see what and how they do.
Roadsend
It is a stand alone implementation of PHP that converts PHP code to executable, FastCGI application or stand alone server.
What I liked in Roadsend is that you can choose what to compile: FastCGI application or Stand Alone applications (using MicroServer, but I haven’t tried this) or executable. I like FastCGI – it is patible with many httpd servers including my favorite NGINX. FastCGI script, fetching 100 rows from MySQL database worked with a charm on NGINX.
One more thing I liked in Roadsend – you can compile your code to libraries and reuse that compiled libraries in next your applications. Just don’t forgot that it will work only with Roadsend implementation of PHP.
Another benefit of Roadsend is that they provide ready to use (with Quick and Dirty Guide) scripts to create .deb and .rpm packages and a way to compile it on Windows. Such way would make deployment much easier.
What I don’t liked in Roadsend that it is a stand alone implementation of PHP and you are limited to extensions and features that Roadsend provide. Moreover, they provide only few popular extensions. I think somewhere there are instructions how to port/embed/bind other PHP extensions to Roadsend, but I haven’t found them.
Another disturbing thing is that you can’t control number of FastCGI processes like you do in PHP-FPM or with standard PHP in FastCGI. Nothing is mentioned in manual about that.
If you are limited to PHP Standard Library, MySQL or SQLite, PCRE, XML, CURL – Roadsend may be very useful for you.
phc
phc is a PHP compiler that converts PHP code to executable or PHP extension.
I like the idea of Web application as PHP extension but the main issue in my point of view that compiled PHP extension is called by __MAIN__() function. So, without small hacking of extension C code you can’t have two Web applications as PHP extensions on same server. If they would change function name from __MAIN__() to something more usable like phc_extansionname() – it would be easier.
Another thing I liked in phc is that they use embedded PHP for compilation. So it should be compatible with all PHP extensions.
I like the way they do it in phc: PHP code converted to C code that uses native internal PHP functions and types.
What I missed is the way to create a PHP extension from any function library written in PHP. I think it would be a great benefit for that compiler.
If you like the idea to have your entire website as PHP extension – you should try this solution.
Other solutions
Oh, there are two more solutions: JAVA based Quercus and .NET Phalanger, but I haven’t tried them yet.
After reviewing and trying Roadsend and phc (I’ve read information about Quercus earlier) now, at least, I know what and how do compilation competitors of HipHop for PHP.
But what Facebook will bring to public after two years of development? Which features? Which limitations? Will HipHop for PHP require many changes of existing projects that I work on?