Welcome to Phalanger v2.0
We have just released Beta 1 of Phalanger v2.0 - The PHP Language Compiler for the .NET Framework. Feel free to download it and play with it. We have prepared just a tiny FAQ-like introduction.
PHP stands for
PHP: Hypertext Preprocessor. It is a popular dynamic language used mainly for server-side web scripting. People usually use the PHP interpreter
http://www.php.net/ to run their PHP code.
- Why would I want to compile PHP?
Obviously, compiled binaries are expected to run faster than interpreted source code. In addition, you may find it advantageous to be able to deploy your web application without source code.
- 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!
- OK, but PHP is not just the language, it comes with a huge number of built-in functions
We have reimplemented these built-in functions in .NET so you can still use them in Phalanger. We've put a great effort into keeping their semantics in sync with the originals.
- So can I take my existing PHP application and compile it in Phalanger?
Yes. Theoretically, you should be able to do this without changing a single line in your code.
- I would like to switch from PHP to ASP.NET but C# scares me
Don't worry, with Phalanger you can write ASP.NET pages and use PHP as the code-behind language. There's no need to learn C# or VB!
- I've been using Phalanger v1.0, what's new in v2.0?
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. You can still download the previous version from
http://www.php-compiler.net/.
- 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
- Declare your classes and functions in namespaces using namespace N { ... }
- Access classes and functions in namespaces using new N:::C; N:::C::f(); N:::C::$x;
- Import namespaces to scripts using import namespace System:::Collections:::Generics;
- Declare generic classes and functions using class<:T:> { function<:S:> { } }
- Instantiate generic classes using $d = new Dictionary<:string, string:>;
- Invoke generic functions using System:::Array::ForEach<:int:>($array, $action);
- Instantiate delegates using new EventHandler("MyFunction"), new EventHandler(array("MyClass", "MyFunction")), or new EventHandler(array($instance, "MyFunction"))
- Apply custom attributes to classes, class members, or parameters using ComVisible(false) class C { ... }
- Apply the Exported pseudo-custom attribute to classes or class members that you wish to expose to other .NET languages.
- Use the partial modifier to declare a class that is split into multiple pieces.
- 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 a few days, so stay tuned!
Miscellaneous