Skip to content

Self-contained executable#

To create a self-contained PHP executable, start with a console application, e.g.:


echo "Hello world!";

and a corresponding project file indicating that the output should be exe:

<Project Sdk="Peachpie.NET.Sdk/1.1.2">
    <Compile Include="**/*.php" />

Now compile your project into binaries using the following command:

dotnet publish -c release

This will publish the resulting binaries into the /bin/release/netcoreapp3.1/publish folder.

As the final step, select an operating system to target, e.g.

dotnet publish -c release -r win-x64 for 64-bit Windows, or

dotnet publish -c release -r linux-x64 for Linux.

This creates a self-contained executable PHP application targeting the operating system of your choice.

Size considerations#

A few tips on how to minimize the size of the resulting application:

  • On Linux, you can get rid of culture-specific functionalities and keep just the "Invariant" culture features (cuts about 26MB of data). More detail at
  • Use dotnet-warp to merge DLL files and remove unnecessary IL and methods. More info can be found at


Rename the project file so that it has the .csproj extension, it will work just fine.