PHP for .NET

Phalanger is a PHP compiler that allows you to compile PHP code to MSIL (which can be executed by .NET’s Common Language Runtime). It also enables it to more easily integrate both worlds: it is possible to use .NET classes from PHP, but also to use PHP classes from other .NET software, which is a novelty. Phalanger is compatible with PHP 5.

“Phalanger”:http://www.php-compiler.net:

The Phalanger is a complex solution giving 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. This solution enables developers to painlessly deploy and run existing PHP code on an ASP.NET web server and develop cross-platform extensions to such code taking profit from the best from both sides. Compatible with PHP 5.0, the object model in Phalanger enables to combine PHP objects with the .NET ones. It is possible to use a class written in PHP from a .NET application or even to import a .NET class (written for example in C# or Visual Basic .NET) into PHP scripts provided that this class respects the PHP object model implemented in the Phalanger. The Phalanger is the only existing PHP compiler which produces .NET Framework MSIL bytecode.

From another point of view, Phalanger provides the .NET programmers with the giant amount of practical PHP functions and data structures — many of them reimplemented in the managed environment of the .NET Framework. The whole Phalanger class library (including functions implemented in the PHP extensions) is accessible to a .NET programmer regardless to her favorite programming language together with type information and in-library debugging.

For last but not the least, compilation of PHP scripts gives yet more power to the existing web applications in the Phalanger environment. All the static (run-time immutable) code in the scripts gets parsed and compiled only once and all following accesses to a page benefit from the unleashed execution of the native compilation of the script. Yet the usage of Phalanger is not limited to web applications. The compiler supports output of standalone executables or dynamic link libraries enabling you to create managed PHP console applications or library modules reusable from any other .NET Framework application.

What makes PHP attractive to web developers is not the language’s beauty, but its eiffel-tower-sized pile of API functions. So, what you’d wonder is: are they going to reimplement all that in C#? No, this seems not to be the case. They chose to wrap the current .dll’s containing all these API functions and use them. Probably a wise choice, because it would be a lot of work to reimplement all that.

Phalanger claims to be quite a lot faster than the current (Zend) PHP implementation:

Phalanger benchmark

And there’s VS .NET integration too:

Phalanger in Visual Studio .NET

The current release is verion 1.0 beta 2. It already runs many current PHP applications, such as “PHPNuke”:http://www.php-compiler.net/PhpNuke. It is even possible to use PHP-GTK, god forbid.

Find out more about “Phalanger here”:http://www.php-compiler.net.