This project is read-only.

Introduction

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 maintains the way how PHP web applications are developed and deployed so that the user need not to learn and use the ASP.NET style of web development. Therefore, the migration from PHP interpreter to Phalanger is an easy and straightforward process.

On the other hand, Phalanger comes with many improvements ranging from a major performance boost to source-free deployment and XML based hierarchical configuration. Besides, a few enhancements to the language introduced by the Phalanger version 2.0, called PHP/CLR, makes possible to use almost all .NET features including generics, LINQ, custom attributes, events and others directly from the PHP source code. By virtue of Phalanger, the PHP becomes a first class language for developing ASP.NET component-based web applications and web services, as well as console and WinForms applications. Since version 2.0, the Phalanger is also portable to the Mono platform to a large extent.

FAQ

  • What is PHP?
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!
  • And what about Mono? Does Phalanger version 2.0 work on this platform?
It does in general. However, there may be some issues due to Mono missing features or bugs.
  • 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.
    • 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!
Visit Documentation page.

Last edited Aug 15, 2006 at 10:48 PM by TomasMatousek, version 3

Comments

No comments yet.