How to compile php scripts in ASP.net
By Justin Silverton
Phalanger is a new PHP implementation introducing the PHP language into the family of compiled .NET languages. It provides PHP applications an execution environment that is fast and extremely compatible with the vast array of existing PHP code. Phalanger gives web-application developers the ability to benefit from both the ease-of-use and effectiveness of the PHP language and the power and richness of the .NET platform taking profit from the best from both sides.
Using .net classes
Phalanger supports full interoperability with .NET. This means that you can access almost any .NET classes (written in C#, VB.NET and other managed languages) from your PHP applications. This requires adding several features to the PHP language that allows you to use .NET features like namespace (which are used to organize .NET classes) and generics (used for specifying type parameters of methods and classes). These language extensions are called PHP/CLR and are designed to retain dynamic PHP behavior (for more details see PHP/CLR Language Extensions).
Thanks to the PHP/CLR extensions you can easilly integrate existing PHP and ASP.NET applications, or use classes available for .NET Framework in your PHP application. This gives you for example the possibility to modify open-source PHP applications to use the standard ASP.NET 2.0 Membership (user management) system, which is very powerfull option for integrating web applications.
You can also develop new applications using PHP with the PHP/CLR language extensions and combine PHP and other .NET languages (for example C#) in one project. This gives you the possibility to leverage of the C# strictness in the application logic layer where the safety and strict object orientation is important, but use the simplicity and efficiency of PHP language for developing the presentation layer.
Features
- compiles PHP to the MSIL (Microsoft Intermediate Language), which is byte-code assembly used by the .NET CLR.
- Improves execution speed (because of just-in-time compilation)
- use any .NET object in a PHP application
- Visual studio integration: supports syntax highlighting for PHP source files and debugging
Benchmarks
How much faster is it than the standard version of PHP?

Download
The latest version of Phalanger can be found Here
4 Comments so far
Leave a reply






[…] On the JSLabs blog today, there’s a quick tutorial talking about how to transfer PHP scripts (without much altering, depending on the functionality used) over to be compiled into an ASP.net application. The real key is in the Phlanger software. Phalanger is a new PHP implementation introducing the PHP language into the family of compiled .NET languages. It provides PHP applications an execution environment that is fast and extremely compatible with the vast array of existing PHP code. […]
Wow this is interesting stuff. Thanks for the post!
Interesting idea, but how do PHP programmers feel about this? I find (although I am a .Net/C#/PHP programmer) that most PHP are very wary and avoid MS.
«… are very wary and avoid MD.»
I think you gotta be talking about high school kids, or alike. Why should someone connected to the IT world (as any programmer worth the title) would avoid MicroSoft? It’s like joining the Air Force and avoiding Lockheed Martin…
FYI, I’ve been programming MS programming languages for almost 10 years now, and programming PHP for a year. Professionally, not for kicks. And, as long as you keep your PHP well structured, it’s almost the same, with the combo PHP/Linux being way faster than ASP.NET/WS2003.
Finally, I think everyone should stop messing PHP with the presentation layer: that’s for Smarty and similar templating engines, tied with JavaScript. PHP, just like ASP.NET, is for the logic layer.