Peachpie compiler aims to bring PHP to .Net

Ngoc Huynh

Built with Microsoft’s open source Roslyn compiler, Peachpie leverages .Net’s metaprogramming technologies in PHP.

After Microsoft open-sourced Roslyn, the compiler technology became the basis for a slew of experimental compilers that allow everything from compiling C# to JavaScript, to providing an interactive scripting environment using C#.

Now a recently unveiled Roslyn-based compiler project named Peachpie allows PHP to be compiled into portable class libraries and executed in the .Net framework.

In addition to possible performance gains, compiling to .Net provides PHP developers access to the existing culture of software written for .Net, as well as features of the .Net runtime itself.

Another advantage of using Roslyn: It generates abstract syntax trees (ASTs) from PHP code. Allowing the source code to be transformed by the compiler and made available to the user makes it easier to write analysis tools or applications that modify the behavior of other applications.

Peachpie stems from an earlier project named Phalanger, a PHP runtime and compiler for .Net. Provided as a toolset for Visual Studio 2010 through 2015, Phalanger enabled such tasks as debugging a PHP website directly in Visual Studio.

Many features planned for Peachpie aren’t available yet, as the current emphasis is on providing a working example of the technology. For now, the parser supports only PHP 5, although support for PHP 7 is planned. A basic implementation of the AST is available, but plans are under way to build ASTs using Roslyn’s advanced ISymbol interface. And none of the .Net-related reflection or introspection tools are available yet.

PHP’s broad deployment — it’s been in use for 20 years — guarantees it will remain a common technology choice for rapid Web development. With PHP 7, the language enjoyed a major performance boost and gained its own abstract syntax tree functionality, among other feats.

But PHP’s inconsistent design and piecemeal evolution opened up opportunities for other platforms, such as Node.js, to step in and offer a more modern set of solutions. (PHP debugging, for instance, has long been problematic).

Peachpie isn’t likely to arrest that trend, but it will at least provide a way for both .Net and PHP developers to leverage what each development environment has to offer: PHP’s breadth of existing applications and development expertise and .Net’s runtime and metaprogramming facilities.

Share the news now

Source : http://www.infoworld.com/