Running PHP scripts on .NET Core

gpeipman
18.9K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Peachpie framework

Peachpie is attempt to get PHP scripts running on .NET Core with minimal effort of work by developers. To convince you there is reason to do it, take a look at Peachpie benchmarks. They have also sample WordPress project available to show that it is also possible to run on .NET COre the real things built on PHP.

Getting started

Run these commands on machine where .NET Core is installed.

mkdir MyWebSite1
dotnet new -i Peachpie.Templates::*
dotnet new peachpie-web
cd MyWebsite1.Server
dotnet restore
dotnet run

Now open browser and move to http://localhost:5000 page.

PHP pages are held MyWebsite1 project. This is referred from MyWebSite1.Server where code is built and run.

PHP script here is simple.

<?php

echo "Hello .NET Core!";

?>

Demo

This is how web server is initialized and run in Program.cs file of .NET Core application.

Click to run the .NET Core Web app.

References

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content