peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.38k stars 203 forks source link

Is it possible to run PHP as a static file with .NET Core? #141

Closed binn closed 6 years ago

binn commented 6 years ago

What I mean by this is, ASP.NET Core creates a folder named wwwroot and that's where the server's static files.

Can I store PHP files in there, and per request they just "work," like many webservers do. If not, can I somehow add compatibility to this, or is there any alternatives that support this?

jakubmisek commented 6 years ago

This is the main difference with Peachpie - PHP source files are not treated as static files. .php files are source files as .cs files are. They are compiled and the server actually runs the compiled .dll.

If you have created a project file (https://www.peachpie.io/getstarted) simply run dotnet run and all files are compiled for you. You can trigger re-compilation when source files change by using dotnet-watch tool (https://github.com/aspnet/Docs/blob/master/aspnetcore/tutorials/dotnet-watch.md).

binn commented 6 years ago

Ah, @jakubmisek I was looking for something more like "throw in static file, get it on web-server, no compilation needed." type thing, so I wouldn't have to recompile my .NET core project every time I want to do some testing. Does anything similar exist, or is it possible to have some kind of reverse proxy to do this?

jakubmisek commented 6 years ago

Do you recompile your C# project every time you change its source code?

binn commented 6 years ago

Yes I do.

binn commented 6 years ago

My development process goes something like dotnet run dotnet restore //make changes dotnet publish //copy files to server dotnet output.dll //via cron job or something

I want to have a way to just make a "small file" throw it in my wwwroot directory, to do some serverside code, such as uploading test.php to wwwroot/tests/ and then just browse and view my tests. No need to recompile, no need to restart my webserver.

jakubmisek commented 6 years ago

can you just throw a .cs file somewhere and run it without compilation? the same

binn commented 6 years ago

Is that really possible? Let me have a look.

jakubmisek commented 6 years ago

no

binn commented 6 years ago

Yeah, that's what I'm looking to do. For example with IIS or Apache I can just throw in a php file in my public directory and it'll run on call. Is there any way to do this with ASP.NET Core, or is this the only way?

jakubmisek commented 6 years ago

I would suggest to start on https://docs.microsoft.com/en-us/aspnet/core/