Thursday, December 01, 2005

Phalanger - the PHP Language Compiler for .NET Framework

Main Features

The aim of the Phalanger project is to create a module enabling execution of PHP scripts on the Microsoft .NET platform. This module is cooperating with the ASP.NET technology enabling it to generate web-pages written in PHP the same way ASP.NET pages are.

In contrast to the original PHP interpreter, our module is compiling the scripts into the MSIL (Microsoft Intermediate Language). While the first page access is delayed due to compilation, all following accesses benefit of the fast execution of the native code which is always far more effective than script interpretation. This gain is most important in case of common PHP-script libraries (for example PHPLIB, PEAR, Nuke etc.) which are complex yet immutable and thus their script files are compiled only once. On the other hand there may be some code in the PHP scripts which is not known in the time of compilation and has to be compiled at run-time. The .NET platform fully supports run-time code generation. Although this procedure handicaps script compilation a little, it is known that PHP constructs imposing run-time compilation are used rather rarely and if, there is not much code to deal with.

The principal goal of our project is to enable full functionality of existing PHP scripts without any modification. The only condition is that these scripts do rely neither on special functionality provided by the UNIX platform or the Apache server nor on undocumented, obsoleted or even faulty functionality of the PHP interpreter. The built-in PHP functions provided to programmer by the PHP interpreter (for example string and array manipulation etc.) have to be reimplemented to reach this goal. They are rewritten in the managed .NET environment, namely in C#, and thus many of these functions will be reusable by other .NET application programmers.

In addition to the built-in ones, there are external functions which are dynamically linked to PHP. These provide additional functionality to PHP programmers such as database access, image manipulation or data compression etc. Since there is a huge amount of such libraries and there will be even more of them in future, it is impossible to reimplement them all in C#. That's why there is a component in our project enabling the external functions to be called from the .NET platform and thus used not only from the PHP scripts but also other .NET languages such are C# or VB.NET.

In addition to the PHP compiler, our project contains a component integrating PHP script editing into the Visual Studio .NET environment, version 2003.
Post a Comment