๒๒/๑๒/๕๐

Phalanger - The PHP Language Compiler for the .NET Framework

http://www.codeplex.com/Phalanger
http://php-compiler.net/

October 2006: Two of Phalanger authors - Tomas Matousek and Lada Prosek were
hired by Microsoft (congratulation and good luck!). The new lead developer for
Phalanger is Tomas Petricek (reach him at tomas@tomasp.net).


Phalanger overview
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 gives 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 taking profit from the best from both sides.
Phalanger and existing PHP applications
Phalanger provides PHP language and standard library implementation that is compatible with most of the existing PHP applications including many large open source PHP projects (see Phalanger apps section for more details). Phalanger compiles PHP scripts into MSIL (Microsoft Intermediate Language) which can be executed by .NET or Mono runtime. This runtime executes MSIL code using JIT (Just-In-Time) compilation, which makes the execution far more effective than interpretation and significantly improves application speed.
As part of Phalanger project we also implemented standard PHP library functions (for example string and array manipulation etc). These functions are reimplemented using managed language (mostly C#) and have very good performance. Thanks to the managed code the implementation is also more secure and the security can be configured using standard .NET tools. Phalanger also supports calling native PHP4 extensions which makes it possible to use most of the PHP functions and classes.
Phalanger is using the ASP.NET framework internally, but only for implementing HTTP request and respons handling, sessions and cookies. The page rendering is still the same as in PHP which gives you full control over the generated code and also compatibility with existing PHP applications.
Enabling PHP to use .NET classes
Starting with the 2.0 version, Phalanger supports full interoperability with .NET. This means that you can access almost any .NET classes (written in C#, VB.NET and other managed languages) from your PHP applications. This requires adding several features to the PHP language that allows you to use .NET features like namespace (which are used to organize .NET classes) and generics (used for specifying type parameters of methods and classes). These language extensions are called PHP/CLR and are designed to retain dynamic PHP behavior (for more details see PHP/CLR Language Extensions).
Thanks to the PHP/CLR extensions you can easilly integrate existing PHP and ASP.NET applications, or use classes available for .NET Framework in your PHP application. This gives you for example the possibility to modify open-source PHP applications to use the standard ASP.NET 2.0 Membership (user management) system, which is very powerfull option for integrating web applications.
You can also develop new applications using PHP with the PHP/CLR language extensions and combine PHP and other .NET languages (for example C#) in one project. This gives you the possibility to leverage of the C# strictness in the application logic layer where the safety and strict object orientation is important, but use the simplicity and efficiency of PHP language for developing the presentation layer.
Developing .NET/Mono applications or libraries with PHP
Thanks to the full .NET/Mono support it is also possible to develop all kinds of .NET applications using PHP language. This includes applications with Windows Forms/Gtk# user interface, class libraries and web applications build using the ASP.NET infrastructure. This allows you to develop ASP.NET style applications which benefits from the ASP.NET features like code separation using code-behind, ASP.NET controls (including any third-party controls) and other. You can use this Phalanger project for smoothly porting PHP applications to the ASP.NET infrastructure, because you can make the original PHP application a part of a larger ASP.NET system, but still write all the source code in the PHP language.
Using this option you can also compile existing PHP projects to standard .NET assembly and use it in any .NET application. Using this technique you can use many of the very usefull and publicly available PHP projects in .NET as well. Phalanger contains two different compilation modes - the first mode (called legacy) is fully compatible with standard PHP and you can use it for compiling any PHP scripts, however using PHP scripts compiled in legacy mode is a bit more difficult. To make using PHP objects from C# as simple as possible we also introducted pure mode in which you have to follow a few additional rules (like specifying all source files during the compilation instead of using includes), but it gives you full .NET interoperability, which means that you can use class written in PHP directly from C#!

The possibility of developing fully .NET/Mono compatible application using PHP language is demonstrated on the attached screenshot where you can see Gtk# application written in PHP running on Fedora Core 6. You can visit the Tutorials section of this page for more examples including Windows Forms and ASP.NET applications.
Visual Studio Integration
Visual Studio supports the integration of additional languages into the editor using the VSIP (Visual Studio Integration Package). Thanks to this possibility we were able to implement Visual Studio extensions for PHP developers. This extensions includes wide range of project templates including Legacy PHP Application, Windows Forms Phalanger Application, ASP.NET Application written in PHP and many other.
Syntax highlighting for PHP source files is a must-have for every IDE and we’re working on support for InteliSense as well. You can also use the Visual Studio debugger for finding bugs in your PHP applications (running on Phalanger). The debugger allows you to set breakpoints in the source code, step through the code and view values of variables, however we are still working on improving the full VS.NET support.
Requirements
Phalanger runs on Microsoft .NET and Mono. If you want to use it with .NET you’ll need Microsoft .NET Framework 2.0 (which runs on Microsoft Windows 2000/XP/2003/Vista) and optionally Internet Information Services (IIS) with ASP.NET installed for hosting Phalanger web applications. For Mono, we recommend using the latest Mono package and optinally Apache web server with configured Mono support (using mod-mono). To benefit from the additional Visual Studio integration feature a Microsoft Visual Studio 2005 is required (Express editions of Visual Studio unfortunately can’t be supported because of licensing limitations).

ไม่มีความคิดเห็น:

Google