The purpose of this page is to get you started with PeachPie quickly. The following steps let you to create a minimalistic project containing PHP files and then compile and run them on top of .NET Core.

The second option is to create an ASP.NET Core application that runs a website with compiled PHP. Open the command prompt in a new directory and run the following commands:

create and run web project

dotnet new web -lang PHP
dotnet run -p Server

The dotnet new command creates a new project and downloads all the necessary dependencies. The application then compiles and runs a built-in web server on http://localhost:5004. You can access the page in the browser and see the result of index.php.

The newly created web application actually consists of two projects - Server and Website. The first one is a C# .NET Core app that initializes the web server and passes requests to scripts in the second project. You can integrate this solution with a regular .NET Core MVC application with your additional configuration.

The third project type is a class library. The following command creates a project that builds a .dll file out of your PHP files to be used as a library that can be referenced by other projects - either C# or other PHP projects.

create and build class library project

dotnet new classlib -lang PHP
dotnet build

This kind of project can be used purely as a dependency to other projects. The contained classes and interfaces are exposed as regular .NET types. The included script files and global functions are also accessible, either by the PeachPie API or seamlessly within another PHP project that references this library.

Start the project by pressing F5 and let VSCode create the initial tasks.json and launch.json files for .NET Core.

Edit launch.json to point to the actual build result.

The steps above add support for PeachPie diagnostics and breakpoints in PHP code within a PHP project in VS Code. The building and debugging of the application is handled by the .NET runtime and debugger.