Public Preview of Peachpie 0.4.0

There has already been a considerable progress in the Peachpie project in 2017, as many new functionalities were implemented. Therefore, we upped the version of Peachpie compiler to 0.4.0-Preview.

As many of you probably know by now, Peachpie is a reimplementation of PHP into .NET and .NET Core, including a complete compiler built on Roslyn and a corresponding runtime for the compiled programs. Therefore, all the PHP features have to be implemented from scratch in C#, which unsurprisingly takes quite a long time. As a result, PHP programs run in the .NET environment, with increased performance, security, maintainability and both-way interoperability with other .NET languages.

Many new PHP functionalities have been added in Peachpie as of late, leading us to up the version number to 0.4.0. With this update, we aim for a majority of the PHP functionality already being compilable and able to run on top of .NET.

Try it yourself

In order to try out Peachpie compiler, there are two ways of getting started. In this blog post, we will demonstrate the first one – a .NET Core project. The second option would be to utilize the peach.exe utility and compile the programs on the command line (see here for more details).

You can also fork our sample repository with some examples of utilizing Peachpie, or contribute your own samples to this repo.

New functionalities

The PHP language provides its programs with a plethora of features that have to be implemented, emulated or simulated in the same way in Peachpie. As of today we have added support for the magic methods __get, __set, __invoke, __call, __callStatic etc. We also already implemented several special functions that modify the scope of local variables or parameters (func_get_args(), compact(), parse_str(), etc.). This requires support in both the compiler and runtime and allows developers to do things that are otherwise not possible in other .NET languages. In addition to bug fixes and hundreds of newly supported PHP functions, there are also more PHP operators in Peachpie 0.4.0, an initial version of a MySql extension built on the MySql .NET Connector, many optimizations and initial support for compile-time error reporting.

If you are curious to see a full list of additions, you can check out our GitHub commits to see the progress.

To Do

Do not expect a full functionality yet. There are still many functions not included in Peachpie, as well as some PHP constructs like eval(), assert(), anonymous classes, lambda functions or traits.

In addition, we are planning something that is not possible in PHP and we can provide it within Peachpie thanks to the .NET platform. We cannot divulge too many details on this project yet, but we believe it will be very useful for PHP and .NET developers alike.

Other notable items on our to-do list that have not yet been included are the use of async for I/O operations (like waiting for DB connection), use of .NET generics similar to support in the Hack language or semantic and type analysis in the compiler itself to avoid errors without the need or running the program.

Visual Studio Code

In case you missed it, we have created an official Peachpie extension for Visual Studio Code, as we previously announced in an older article. You can find the extension in the VS Code Marketplace.

Please note that the version of ‘Peachpie.Compiler.Tools’ and ‘Peachpie.App’ in project.json has to be changed to 0.4.0-*.

VSCode GIF

We are making steady progress with the compiler, which should now be very close to being able to run real world applications. Feel free to try out our samples on GitHub to get an idea of all the interoperability options. Our VS Code extension should make this experience very comfortable and simple.

Share this article:Share on FacebookShare on VKPin on PinterestShare on Google+Tweet about this on TwitterShare on LinkedInShare on Reddit
Posted on January 10, 2017, in category Announcement, Information, News, Samples, tags: , , , , ,