I’ve used the Phalanger 1.0 compiler successfully on several projects, and am happy to see they have now upgraded the code base to version 2.0 of the .NET Framework,

Phalanger - The PHP Language Compiler for the .NET Framework

Phalanger v2.0 runs on .NET Framework 2.0 and finally supports full .NET interoperability. It means that you can directly use or extend any .NET class; be it System.Xml.XmlDocument, System.Windows.Forms.Form, or System.Web.UI.WebControls.DropDownList. We also support delegates, events, generics, and even some basic LINQ.

A couple of points worth noting,

* Why would I want to compile PHP to .NET?

For a number of reasons. Unlike the PHP interpreter, .NET provides a secure environment. No web server crashes, no buffer overruns. We generate verifiable .NET assemblies that easily interoperate with everything that runs on CLR. You get access to zillions of useful classes available to other .NET languages like C# or VB!

* I’m a PHP guru, give me a rapid intro into the extensions to PHP language that you’ve made in order to interoperate with .NET
o Declare your classes and functions in namespaces using namespace N { … }
o Access classes and functions in namespaces using new N:::C; N:::C::f(); N:::C::$x;
o Import namespaces to scripts using import namespace System:::Collections:::Generics;
o Declare generic classes and functions using class<:T:> { function<:S:> { } }
o Instantiate generic classes using $d = new Dictionary<:string, string:>;
o Invoke generic functions using System:::Array::ForEach<:int:>($array, $action);
o Instantiate delegates using new EventHandler(”MyFunction”), new EventHandler(array(”MyClass”, “MyFunction”)), or new EventHandler(array($instance, “MyFunction”))
o Apply custom attributes to classes, class members, or parameters using [ ComVisible(false) ] class C { … }
o Apply the [ Exported ] pseudo-custom attribute to classes or class members that you wish to expose to other .NET languages.
o Use the partial modifier to declare a class that is split into multiple pieces.
o When extending a CLR class without a parameterless constructor, invoke the base class constructor using function __construct($x) : parent($x) { … }

* Is this it? I want to know more!

Detailed documentation is under way. We are also going to release Visual Studio 2005 integration package in the near future, so stay tuned!