Announcing the Public Preview of Peachpie 0.2.0

We are happy to announce the release of Peachpie 0.2.0. The latest preview of the PHP compiler to .NET is now publicly available as a set of NuGet packages for everybody to try.

Peachpie Platform

Peachpie is an open source project targeting Roslyn and the PHP language in order to provide a compiler, CodeAnalysis and .NET runtime for legacy PHP applications. It supports both major frameworks – .NET 4.6, .NET Core 1.0 – allowing to compile and run PHP code on Windows, Mac, Linux or Android, with the possibility to natively interoperate between the PHP and .NET worlds.

With release 0.2.0 we are providing all the necessary dependencies as NuGet packages – both the compiler and runtime platform can simply be referenced, dotnet and the NuGet platform then download and install everything automatically. Since the platform is built on top of the .NET project system, there are no additional installation steps needed. Peachpie blends into the .NET ecosystem seamlessly, promoting PHP into the world of .NET languages.

>> dotnet run
Compiling ConsoleApplication1 for .NETCoreApp,Version=v1.0
Peachpie PHP Compiler.

Compilation succeeded.
    0 Warning(s)
    0 Error(s)

Time elapsed 00:00:01.8785931
 (The compilation time can be improved. Run "dotnet build --build-profile" for more information)

Hello World!

The Most Prominent Changes

In addition to fixes and new features, like more PHP functions and constructs being supported by both the compiler and runtime, there are some design changes in the project.

  • The NuGet packages you need are ‘Peachpie.App, 0.2.0-*’ and ‘Peachpie.Compiler.Tools, 0.2.0-*’.
  • Peachpie is automatically tested on https://travis-ci.org/iolevel/peachpie.
  • Peachpie supports the syntax of PHP 7.0; however, not all constructs are compilable yet.
  • Currently, Peachpie is built on top of our own fork of Roslyn instead of the official package, since we are using some Roslyn internals.
  • We have prepared hybrid samples as a part of the Peachpie source code itself. The samples reference Peachpie from its own sources, thus allowing a continuous development and debugging of PHP code and the compiler within one solution.

See the latest commits to the master for a complete list of changes.

Demo Application

There are currently two major uses of Peachpie to play with. Both are on .NET Core, so it can run for free and open source on Windows, Mac and Linux. There are some already working alternatives on the full .NET Framework, as well.

See our ASP.NET Core repository demoing ASP.NET Core running compiled PHP sources. The solution works upon simply pressing F5 within Visual Studio Code or calling `dotnet run` from the command prompt.

peachpie-php-run-debug

An even simpler demo can be found here, showing a basic command line application written in PHP. Start the project using VS Code or ‘dotnet run’ directly.

Make sure you restore the packages before running the demos above by typing ‘dotnet restore’. The command downloads all the necessary packages and both Peachpie compiler (Peachpie.Compiler.Tools) and the runtime platform (Peachpie.App). Take a look at the contained `project.json` files defining all the dependencies and compiler options.

Still, Peachpie should not yet be viewed as a fully functioning compiler that could run entire PHP applications. Instead, it should be considered a work in progress and its primary use at the moment is merely for demonstration and experimentation purposes. However, as we are implementing more and more PHP constructs and functions, the compiler will soon be able to run full PHP apps.

Share this article:Share on FacebookShare on VKPin on PinterestShare on Google+Tweet about this on TwitterShare on LinkedInShare on Reddit
Posted on November 14, 2016, in category Announcement, News, tags: , , , , ,