Hacker News new | past | comments | ask | show | jobs | submit login
PeachPie Compiler: Compile and run PHP on top of .NET runtime (peachpie.io)
69 points by lemper 3 months ago | hide | past | favorite | 20 comments



I highly recommend paying attention to https://docs.peachpie.io/compatibility-status/ -- there is still a lot of work to be done, and they are comparing to a really old version of PHP. There have been a lot of new features since 8.0.


Amateur here. This is good for what? Why somebody should use this instead of normal?


From the README:

> Project goals: Both-way interoperability, Full .NET compatibility, Security, Cross-platform development, Increased performance - https://github.com/peachpiecompiler/peachpie

So seems they're aiming to use the PHP language but on a different runtime, for the listed reasons. Sounds kind of out there, but seems at least the .Net Foundation supports it, I'm guessing for the same reasons.


IMHO, besides the fun to create such a project (and all the thibgs you learn while doing it), it's not for much. It tries to bring a technology somewhere (presuambly the desktop, as asp.net and PHP are already comparable) it's not designed for - which will bring you in trouble sooner or later. It's like JavaScript on the server, it's ok but there are languages better suited for this environment.

It's much faster to learn C# in the long term than to run PHP on top of .Net.


C# has poor man's PHP baked in these days:

https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...

And, it's getting better over time:

https://github.com/dotnet/csharplang/issues/4935

This is essentially how I respond to web requests in my codebases right now:

  var table = $@"<table>
    <tr><th>Name</th></tr>
    {string.Join('\n', items.Select(i => $"<tr><td>{i.Name}</td></tr>"))}
  </table>";


The defining feature of PHP isn't really string templating, but its shared-nothing architecture.

https://slack.engineering/taking-php-seriously/

I would consider poor man's PHP as something to reimplement that architecture, rather than any particular language feature.


Hi, my name is:

   <script>Alert("hi")</script>


I fail to see why anyone sane would use this way over Razor files.


I use it to avoid the gauntlet of AspNetCore dependencies and weird editor bs around cshtml files.


Kind of makes my point then.


Migrating a legacy PHP code-base to .net maybe


we have attempted to use it for that, but it was really hard and we ended up rewriting from scratch.

The activity graph on GitHub says it is mostly dead. There is some activity, but at best it is in maintenance mode. It used to be sponsored, but not anymore IIRC

https://github.com/peachpiecompiler/peachpie/graphs/contribu...


It looks like this compiles PHP code to a .net binary but it doesn't support all of PHP so it's kinda useless for most projects.

Benefits of this are dubious at best. The php interpreter is already a low level C project so why replace that with .net? Makes no sense.


A major difference will be that PeachPie produces a compiled deploy artefact, while mainstream PHP is interpreted (albeit with heavy opcode caching and a JIT in production)


> The php interpreter is already a low level C project so why replace that with .net?

You are comparing apples with pies here. PHP is a interpreted language, while .NET is a compiled target.

However, this peachpie project seems to be far from stated goal and more of a research project currently.


May also be useful for creating automatic language support from a single codebase. For example, Amazon uses JSII to build a typescript library into Python, Go, dotnet, etc.

Maybe this tooling will help add PHP to that list.

That way you are not maintaining 6 codebases.

https://github.com/aws/jsii


I'm not sure why anyone would use it, but it was probably a fun project to make. I do think the statement on their landing page which reads: "Compile and run PHP on top the modern, secure and highly performant .NET runtime" perhaps is a little disingenuous. This might just be me, but I read it as though they imply that PHP isn't those things, which would be a silly statement to make in 2024.


You have a php project, and you want to use .net libraries.


For obfuscation reasons mainly. Hide your genius code from a php base so your IP is not poached/discovered by Amazon and the likes who love to get brilliant open source made project, move a line and call it their own.


Some might dislike your snark but obfuscation is a good use for this.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: