Serdar Yegulalp
Senior Writer

Peachpie compiler aims to bring PHP to .Net

news analysis
Mar 14, 20162 mins

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.

Serdar Yegulalp

Serdar Yegulalp is a senior writer at InfoWorld. A veteran technology journalist, Serdar has been writing about computers, operating systems, databases, programming, and other information technology topics for 30 years. Before joining InfoWorld in 2013, Serdar wrote for Windows Magazine, InformationWeek, Byte, and a slew of other publications. At InfoWorld, Serdar has covered software development, devops, containerization, machine learning, and artificial intelligence, winning several B2B journalism awards including a 2024 Neal Award and a 2025 Azbee Award for best instructional content and best how-to article, respectively. He currently focuses on software development tools and technologies and major programming languages including Python, Rust, Go, Zig, and Wasm. Tune into his weekly Dev with Serdar videos for programming tips and techniques and close looks at programming libraries and tools.

More from this author