Read the title one more time. Yeah, I said it. PHP, one of the most popular web development languages, runs faster when it’s executed as compiled .NET Common Language Runtime (CLR) using Phalanger 2.0 than it does running natively under the Zend interpreter.
What the hell is Phalanger?

Credits to Das Tierlexikon (The Animal Encyclopedia)
The animal in the image above is a Phalanger, but what I’m referring to is the Phalanger Project, which can be used to compile PHP applications into .NET binaries, which can execute in an ASP.NET application just like any other binary.
PHP projects compiled under Phalanger 1.0 and 2.0 perform better than those interpreted with Zend
AjaxNinja reader vjeran tipped me off to the existence of a .NET technology that makes PHP run “twice as fast,” and after a bit of poking around I finally found the Phalanger project and its benchmarks page, where, indeed, it was revealed that Phalanger 2.0 serves up phpBB pages at approximately twice the rate as the Zend engine.
Here’s the text from The Code Project’s piece on Phalanger:
We tried two kinds of performance tests – the micro-benchmarks show how fast is the execution of the most important elementary operations (like calling a function, calling function by name, array access, etc.) on Phalanger and PHP interpreter.
The results are very good – from the 25 tests in total, Phalanger is faster in 19 tests and the difference in the 6 remaining tests is very small. The second test compares performance of the PhpBB forum application running on PHP and Phalanger. The results show that Phalanger was able to serve almost two times more pages per second!
Phalanger extends the PHP language
One of the attractive features of Common Language Runtime (CLR) compilers is that you can borrow a feature from any of the CLR programming languages in any .NET project. When I was developing a credit-card validation system for a business I often imported some of the VB.NET string manipulation functions into my C# applications, simply because VB.NET has better options for performing simple whitespace removal and a number of other menial string-related tasks.
When you create a PHP application with Phalanger, you gain access to all of the features of the .NET framework! So if you wanted to use the .NET membership framework within a PHP5 application, you could accomplish this using Phalanger.
Phalanger integrates PHP development into Visual Studio
So long as you are not using the express editions of Visual Studio, Phalanger enables you to create PHP Web Application projects in Visual Studio.
This also means that you can use the Visual Studio debugging tools for fault-checking your PHP applications, break points et al.
Some drawbacks to using PHP with Phalanger
Phalanger might produce more scalable and better performing PHP applications, but the using Phalanger for running PHP eliminates some of the most attractive features of PHP in the first place:
- Less hosting options - The strongest feature of PHP is its ability to run on a wide number of different operating systems and server configurations. .NET applications only execute on Windows servers running Internet Information Services (IIS), thus your choices for which PHP hosting service you use are limited to just Windows/IIS configurations should you compile with Phalanger.
- No inter-operation with unmanaged modules – If you referenced unmanaged* third-party modules in a PHP application that you wanted to run under Phalanger for the performance benefits, you’d be unable to. All .NET code is managed code.
- No IntelliSense support for PHP, yet – Although they may add IntelliSense support in future releases, if you’re used to relying on it for ASP.NET development, then you may feel a bit naked without it if you try jumping into PHP development for .NET. This really isn’t a problem for traditional PHP developers though.
For ASP.NET developers, I recommend checking this tool out so you can try playing around with PHP/.NET hybrid projects.
For PHP developers, if you’re worried about the performance of your PHP applications then I’d give this a look; if not for that, give it a look for the sake of being able to borrow .NET framework features and use them natively in your PHP applications.
If you enjoyed this post, make sure you subscribe to my RSS feed!
Comments 23
You have similar design as mine and good posts.
Posted 09 Sep 2007 at 12:57 am ¶Use APC, you will get C-based PHP runtime executes twice as fast as Phalanger.
Posted 09 Sep 2007 at 9:01 am ¶Do you have some benchmarks that can enforce that assertion? We’re all about objectivity here.
Posted 09 Sep 2007 at 10:35 am ¶If you’re comparing PHP without APC or another bytecode cache, you’re comparing apples and oranges here.
Check out: http://itst.net/654-php-on-fire-three-opcode-caches-compared
And to the previous commenter’s assertion that APC based PHP will be twice as fast as Phalanger, the 190% speed improvement in the referenced article seems to support that.
Also, the Phlanger PHPbb test is little off. It was run on a pentium M 1.8Ghz laptop using windows XP. It’s not exactly the environment most people will use when running PHP (which can be seen pretty clearly by the paltry 6 requests per second it pumped out). Also, everything was run on the same box (including the test harness itself).
Posted 09 Sep 2007 at 12:32 pm ¶Dom,
Great comment! I’m simply comparing traditional PHP execution using the Zend interpreter against the .NET methodology using Phalanger; the comparison stands as valid (rather than Apples and Oranges) from that point of view.
I did not write the article with the intention of determining what the absolute best performance system for PHP is, given that this is a .NET blog. I happen to like PHP and I saw Phalanger as an exciting opportunity to incorporate it into some of my .NET projects.
When I wrote the article I was aware of different PHP compilation techniques, but I simply was writing about PHP compilation in the scope of .NET.
And what you say about the bench-marking is also true; I think this merits some more thorough bench marking on the behalf of the Phalanger developers, don’t you?
Posted 09 Sep 2007 at 12:41 pm ¶PHP runs five time faster when it is run under Java: http://www.caucho.com/resin-3.1/doc/quercus.xtp
Posted 09 Sep 2007 at 2:08 pm ¶You say that it is an apples to apples comparison but you have a very old version of php and no byte cache running against an optimised native executable.
and no mono doesn’t count as it’s definately not ready for large scale applications.
Posted 09 Sep 2007 at 4:21 pm ¶My insticts would tell me that .NET should be faster but PHP is definately no slouch when set up properly, all you have done is basically hyped a half truth in a true Microsoft way, well done.
And I definately won’t mention anything about .NET being platform independant considering it runs on exactly 1 platform
@Anonamoose,
If you can point out how my article is only telling half the truth, please do so. Is it not true that PHP compiled in .NET runs twice as fast as Zend interpretation according to the Phalanger group?
A half-truth would be if I claimed that Phalanger was the fastest available platform for PHP, which I didn’t.
In addition, if you read my article all the way through, you would have read the area where I addressed platform dependence
Posted 09 Sep 2007 at 5:16 pm ¶@Aaronontheweb
A half-truth would be if I claimed that Phalanger was the fastest available platform for PHP, which I didn’t.
Stating “Attention: PHP executes twice as fast when it’s run on ASP.NET” implies that it is faster then PHP and the assertion is it is for all aplications even though one is given as a token example.
If you stated that PHP was run in an non-optimal setup on a webserver that is far from friendly to PHP not to mention the old version then it would be alot more factual.
If you re-run these tests with a fair testing environment (linux/apache/op cache vs IIS/.NET or even just an op cache on IIS) and it is still faster then I’ll be the first to say ‘wow well done’, untill then it is complete utter FUD.
In addition, if you read my article all the way through, you would have read the area where I addressed platform dependence
Well this is a start, there is more to platform indepedance then hosting options
The world doesn`t need more people advertising FUD on both sides get an ounce of skeptiscism and don’t be a puppet.
Posted 09 Sep 2007 at 6:36 pm ¶@Anonamoose,
I didn’t run any of these tests; I reported on what the Phalanger group did. You should tell them to rerun those tests on a fair environment if you have a problem with how they did it.
If I wrote a headline saying that “Attention: Under Windows IIS PHP Can Be Compiled with Phalanger to Run at Approximately 100% Faster Speeds Than it Can Under Traditional Zend Interpretation” do you think anyone would read it?
Blogging is just as much about writing effective copy as it is about providing sufficient cause to start discussion. Titles like this one draws enough interest to spark the discussion necessary to ultimately produce better information for my audience.
Look at the valuable information that the comments for this article has yielded; now people who are really interested in learning about not just .NET, but about increasing the performance of PHP, have a list of resources they can turn to for doing just that. The criticism that some of the visitors to my site have provided via comments ultimately improves the quality of information on my site.
Blogging is not about the original writer being right or wrong, but it is ultimately about gathering the most complete and best information; I alone couldn’t possibly gather all the possible ways you can optimize a PHP application. Readers like you and others who leave feedback complete the information gathering to one location.
I’ve not cast FUD on anything (Fear, Uncertainty, and Doubt; I had to look it up.) If anything I’ve objectively directed my readers to the facts on codeproject and the Phalanger website, regardless of what some readers may think of said facts. I’ve entertained criticism and discussion in a fair and respectful manner; I could choose to moderate comments or ignore criticism entirely, but I haven’t because criticism of my articles ultimately makes for better information, which is my objective. If it takes a controversial title to acquire such information, then so be it
I really don’t care much about what my readers think of me personally, but I care a lot about writing on subjects that they enjoy and I care a lot about having the best possible information, even if it’s provided from readers, other bloggers, or my harshest critics.
I’d be more than happy to write a subsequent post about PHP optimization/bytecode caching techniques should the readers of this blog want to read it. I even have a catchy title thought of for it already
Regardless, thank you for your comment!
Posted 09 Sep 2007 at 7:09 pm ¶If you link to an article and then add supplimentary comment supporting it then you are in fact supporting the original assertion.
Posted 09 Sep 2007 at 7:52 pm ¶You seem like a fair person and all I’m trying to get at is that pointing at something that will lead to a flame fest and saying ‘don’t shoot the messenger’ is not going to stop people commenting on your article.
You either support something, not support something or be fair and present both sides and let the discusion take place a fourth option I do not believe exists but maybe wrong.
I guess you are just ‘link baiting’ to get visitors which is a real shame, there is so much FUD out there you could use your powers for good not ebil! (that isn’t a mis type).
By the way the article was nicely written even if I don’t agree with the content
I am supporting the original assertion that Phalanger speeds up traditional PHP execution, to be clear. The facts of Phalanger’s tests support this assertion. However if you wanted to demonstrate that original PHP could be improved with bytecode compilation to such a level that it’s indeed faster than Phalanger, that’s an entirely separate issue from comparing the two as they run out of the box with no modification. I would encourage you to run your own tests.
I am very supportive of comments; it seems to me that there’s some interest in other technologies for improving PHP performance, technologies that I was only vaguely aware of, and from these comments I can potentially produce another post on the subject.
Do you think I am being unsupportive of comments? The only reason I’ve replied is to more or less clarify why I produced the article in the first place, for the sake of having my readers understand my blog’s intent. I’m by no means trying to stifle discussion, only stifling attacks against my blog’s integrity and intent
Posted 09 Sep 2007 at 8:44 pm ¶I don’t think your stifling the comments at all which is good, well done you get a cookie but at the same time you do not seem open to the fact that the article is based on an incorrect assuption.
Posted 09 Sep 2007 at 11:09 pm ¶Your support for it is IMHO misplaced and I hope the you do redress it maybe with another article about the Phalanger Project (perhaps an interview with them addressing what I and other posters have said).
Your integrity and that of your site is directly related to how you handle the facts and in this case your defending a flawed article, this is what is known as FUD or to put it another way ‘throw enough mud and it sticks’.
Do you want to be known as just another shrill/fanboy ? or someone that is trustworthy it is up to you.
I’d encourage you to check your email, if you’ve been using a real one.
I’ve had no problem handling the facts; it’s not my fault that you don’t like them.
PHP runs faster when it’s compiled with .NET than it does running on Zend interpretation; this is a fact and its integrity has been weakly challenged but not disproved by any stretch of the imagination.
No one has presented any data demonstrating that out of the box Zend interpretation runs faster than Phalanger binaries. Go ahead and try it; inform us.
In the email I sent you I’ve given you an opportunity to throw some of your own ideas about PHP out there in a full post that i will publish on this site. If you want to use the opportunity to demonstrate methods in which PHP will execute faster than it does with Phalanger then that’s up to you.
Posted 09 Sep 2007 at 11:26 pm ¶Yes, a compiled php is faster than an interpreted php – whats the news?
Posted 10 Sep 2007 at 6:16 am ¶Aaronontheweb,
Attention: PHP executes twice as fast when it’s run on ASP.NET
BAD TITLE, MISLEADING and you know it
Naturally compiled code executes faster then any interpreted code on any platform. That said, there are many ways to speed up php execution on windows or any platform, probably the best is to purchase a copy of Zend Encoder:
http://www.zend.com/products/zend_guard
First time I hear about Phalanger so its an interesting read but a title like: compile PHP code on ASP.net would be *much more* honest and interesting then reading about misleading titles/statements on execution time.
Posted 10 Sep 2007 at 6:39 pm ¶While I think the comments regarding the misleading title are unjust (it’s supported by facts, what more do you want? An Apache group endorsement?), I like your suggested title, as I think it conforms better to the spirit of AjaxNinja’s readership.
Posted 10 Sep 2007 at 7:05 pm ¶There, I submitted the article to reddit, which I have never used before, with the new headline. Let’s see if you’re right about the other title being better, given that it did pretty well on DZone with the original one.
http://programming.reddit.com/info/2nzuz/comments
Posted 10 Sep 2007 at 7:33 pm ¶There is a vs.net plugin that provides intellisense – http://www.jcxsoftware.com/ – although I have never tried it!
Posted 12 Sep 2007 at 7:08 am ¶XRumer is the best program for advertisement!
It’s have CAPTCHA recognizer, email verificator, and a lot of other functions…
But. I forgot link to it
Can you give me URL to the XRumer description? screenshots, etc.
Thanks
Posted 06 Nov 2007 at 6:13 pm ¶I have to agree with aaronontheweb, “BAD TITLE, MISLEADING”.
I’ve developed in pascal, basic, delphi, classic asp, vb, vb.net, c#, java, php, and ruby. Been paid for most of those languages. Point being, anyone who’s ever touched php knows you run with a opcode cacher or whatever they’re calling themselves these days. And the things have been around for more than five years.
The argument of “I just ran it out-of-the-box so it’s a fair comparison” is a poor argument because php’s “out-of-the-box” experience is on linux, not windows. PHP is a dog on windows and everyone knows it:
http://www.google.com/search?q=php+slow+on+windows&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:official&client=firefox-a
Which is why the recent announcement that MS is working with Zend on fastcgi is so interesting.
To further this thread, what’s interesting about php on .net that you didn’t have before is large corporations which standardize on a particular technology (like .net as a platform) now have the ability to run php within their own guidelines. Windows admins, notable for being poor at picking up anything not written about on msdn, should be able to deploy, administer, and support a php app on .net without even knowing it’s written in php.
-Dan
Posted 11 Nov 2007 at 9:19 pm ¶Aaronontheweb, interesting test and article.
Short of splitting hairs, I think we all know the scope of the test fairly well.
Anyway, is the usual installation for LAMP using interpreted php zend thingie?
Posted 20 Dec 2007 at 8:50 am ¶My understanding is typical LAMP installations with no modifications to PHP are just Zend interpretations, yes. XAMPP is a good product for giving it a try if you want to see the performance of traditional PHP in action.
I’ve tried getting Phalanger to work on VS 2005 and it’s a lot harder than it sounds to get that sucker started. I’m running on Vista Ultimate on my new Dell XPS and I’ll be using Visual Web Developer Express; I am confident that Phalanger won’t work for that suite.
Posted 20 Dec 2007 at 12:48 pm ¶Post a Comment