PeachPie is an open-source PHP language compiler and runtime for the .NET Framework and .NET. It is built on top of the MicrosoftRoslyn compiler platform and is based on the first-generation Phalanger project. PeachPie compiles source code written in PHP to CIL byte-code. PeachPie takes advantage of the JIT compiler component of the .NET Framework in order to handle the beginning of the compilation process. Its purpose is not to generate or optimize native code, but rather to compile PHP scripts into .NET assemblies containing CIL code and meta-data. In July 2017, the project became a member of the .NET Foundation.[4]
Origins
PeachPie's architecture is similar to the Phalanger project,[5] which had originally started as coursework at the Charles University in Prague, Czechia.[6][7] It was implemented on Microsoft's .NET compiler platform called Roslyn, utilizing the Roslyn API. Since 2016, the Czech company iolevel has been leading the development of PeachPie.[citation needed]
PeachPie has several advantages over Phalanger, both as a result of the Roslyn API and the reworked architecture of the compiler. While Phalanger was only able to target the full .NET Framework, which only ran on Windows, and cross-platform capabilities were achieved by targeting Mono, PeachPie also allows for a compilation to .NET, thus being cross-platform by default.[8] The benchmarks published to date point to performance improvements of PeachPie compared to its predecessor.[9][10][11] The project contains an advanced semantic analysis, which allows the compiler to generate C#-like symbols for enhanced interoperability features. There are similarities between PeachPie and Facebook's HHVM compiler, which executes PHP on a specially designed virtual machine. However, as Facebook announced in late 2017, version 3.24 of HHVM would be the last release compatible with PHP, as the project would focus exclusively on supporting Facebook's proprietary extension of PHP called Hack.[12] This leaves PeachPie as the only project of this kind with the aspiration to be compatible with past and future versions of PHP.[citation needed]
The project receives considerable support from Microsoft,[13] having been invited to present at the virtual conference .NET Conf [14][15] and featured on Microsoft's "On .NET",[16][17] as well as the .NET Rocks podcast.[18] Since July 2017, PeachPie has been a member of the .NET Foundation. In December 2018, iolevel received the European Innovation Council's Horizon2020 grant to pursue their work on PeachPie compiler.[19][20][21]
Performance: since the PHP code is compiled to CIL and subsequently executed, rather than interpreted, theoretically this should lead to performance improvements.[24] The micro-benchmarks performed by the authors suggest an increased performance over standard PHP in isolated cases[25] and tests have shown that the project is able to run PHP code about twice as fast on Azure.[26] Using the TechEmpower plaintext benchmark, it was measured that WordPress running on PeachPie was able to serve 305,612 requests per second,[27] whereas standard PHP served 45,616 requests per second.[28] PeachPie is also part of the regularly published TechEmpower benchmarking rounds[29][failed verification], where, as of 2019, PeachPie is faster than any other PHP framework appearing in the benchmark.[30][non-primary source needed]Phalanger had also offered considerable performance benefits over a 32-bit Windows version of PHP 5.4.[31][32][33]
Interoperability: the project allows users to interoperate between the PHP and .NET languages. As a result, unusual operations, such as injecting C# lambdas into a PHP Context or inheriting PHP classes in C#, are possible.[34] Therefore, users can utilize PHP libraries in their .NET projects and vice versa.[35]
Additional security: given that PeachPie compiles all the source code into one DLL file, the applications can be distributed without the original source code. The PeachPie project enables entire PHP applications and frameworks to be compiled to the standard .NET DLL format and distributed, for example, as NuGet packages.[36]
Cross-platform capability: since PeachPie can target .NET, which is compatible with the regular .NET Framework, Xamarin and Mono, and runs on Windows, MacOS and Linux,[37] it allows for PHP applications to be developed for all devices and operating systems capable of running .NET.