Release 0.9.11 and Visual Studio

We’re happy to announce version 0.9.11 of PeachPie – the PHP compiler and runtime for .NET and .NET Core. This update introduces a lot of new features, compatibility enhancements and improvements for the project management.

About PeachPie

In general, PHP programs (or rather scripts) run using an application called ‘php’. It implements its own runtime, type system, garbage collection and libraries, everything coded in the C language. PeachPie provides a different approach to running PHP programs.

The scripts are analyzed and compiled into .NET byte code, compatible with a vast array of platforms and devices. This results in cross-platform, safe, managed, source-less .NET assemblies; the same you would get by compiling your C# application. Since PeachPie gives the two technologies a common grounds, it also provides all the advantages and tools .NET has to offer, all while being both-way inter-operable with anything else running on .NET. The resulting assembly also makes use of the entire .NET ecosystem – .NET libraries, garbage collection, system fonts, certificates, time zones and more.

Get started  Documentation

Release 0.9.11

0.9.11 is the first non-preview release. The compilation itself is fast and more user-friendly (better error messages), there is a much improved documentation (https://docs.peachpie.io/) and PeachPie projects work nicely with the new .NET Core, Visual Studio (>= 2017 Update 6) and Visual Studio Code. A lot of functions and libraries have been implemented, support for Phar has been added and more.

Visual Studio 2017 and MSBuild SDK

With Visual Studio 2017 Update 6, it is now possible to provide a so-called project SDK as a NuGet package. So we did it.


What does this mean? A project file (e.g. my-awesome-app.msbuildproj) for your PHP/PeachPie project describes what files will be compiled, what files will be deployed as content and everything else you should already know from Visual Studio and C# projects, including NuGet dependencies to your PHP project.

<Project Sdk="Peachpie.NET.Sdk/0.9.11">
  <PropertyGroup>
    <OutputType>library</OutputType>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**/*.php" />
  </ItemGroup>
</Project>

Now the project file itself is just a few lines of code and you can instantly open it in Visual Studio – it recognizes that the project contains a reference to an SDK that you don’t have and downloads it by itself from a NuGet server. The SDK contains the entire compiler and everything needed for Visual Studio to let you work with a PeachPie project as you are used to with C# projects. All of it happens seamlessly, and the user doesn’t have to install PeachPie or PHP. Best of all, you don’t need any additional Visual Studio extensions for basic functionality (build, debug, diagnostics, code colorization, NuGets, …).

See the documentation on the project file https://docs.peachpie.io/php/msbuild/
or get started to create the project and start compiling https://www.peachpie.io/getstarted

Visual Studio Code

PHP works nicely in Visual Studio Code as well. However, to enable breakpoints in PHP files you’ll need an extension – https://marketplace.visualstudio.com/items?itemName=iolevel.peachpie-vscode

Compatibility

The goal of the PeachPie project is to be fully compatible with regular PHP so the application will need none or very few modifications in order to run on PeachPie. Currently it almost reached the goal. See https://github.com/peachpiecompiler/peachpie/issues for known issues.

However, there are a few exceptions by design:

  • Once the app is running, it is not possible to modify the source code (i.e. a recompilation is needed). This might get implemented in a future version, but not for now.
  • The compiler is very strict and doesn’t allow to compile code containing a possible error.
  • Some functions and PHP extensions may be missing. It is either not possible to implement them in C# or they were simply not needed yet.

Security and Performance

An extensive analysis and the compilation allow for developers to avoid errors in production and to deploy compile-time optimized binaries, with no source code being deployed on the server or to the client.

During the compilation, PeachPie performs its own code analysis and provides a bunch of diagnostics. The compiler also optimizes the code; however, please note that significant performance optimizations are planned for a future release of PeachPie. For the time being, we’ve done a few benchmarks to see what is possible.

Migration from previous versions

All the project files created previously will continue to work; however, it is strongly recommended to make use of the new format. Now, the project makes use of the ‘Sdk‘ attribute making the `PackageReference` for `Peachpie.App` and `Peachpie.Compiler.Tools` obsolete.

Some project properties that were changed or added:

  • `PeachpieVersion` is initialized with 0.9.11 being the default version of PeachPie you compile with.
  • `GenerateDocumentationFile` can be set to `true` so PeachPie creates XMLDoc from embedded PHPDocs. Previously the property was named `GenerateDocumentation`.

Conclusion

With the release 0.9.11 of PeachPie (can be found on https://www.nuget.org/profiles/peachpie) we’ve made another step closer to a final release. The Visual Studio experience is great, projects work nicely in combination with ASP.NET Core or other C#/VB/F# projects and the compilation is blazing fast!

Personally I love how it takes advantages of everything Microsoft and the community implemented for the C# and the .NET ecosystem in general. With PeachPie, the PHP program gets an industry standard debugger, project system, MSBuild, diagnostic tools to measure CPU+memory performance in insane details, deployment to Azure, NuGet package manager, publishing as standalone redistributable app and much more.

Share this article:Share on FacebookShare on VKPin on PinterestShare on Google+Tweet about this on TwitterShare on LinkedInShare on Reddit
Posted on October 2, 2018, in category Announcement, News, tags: , , , , , ,