PeachPie Compiler: Compile and run PHP on top of .NET runtime

69 points by lemper 8 months ago | 20 comments
  • withinboredom 8 months ago
    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.
    • msavara 8 months ago
      Amateur here. This is good for what? Why somebody should use this instead of normal?
      • diggan 8 months ago
        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.

        • chrisandchris 8 months ago
          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.

        • bpbp-mango 8 months ago
          Migrating a legacy PHP code-base to .net maybe
          • mnau 8 months ago
            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...

            • hparadiz 8 months ago
              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.

              • CiaranMcNulty 8 months ago
                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)
                • 0points 8 months ago
                  > 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.

              • SamuelAdams 8 months ago
                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

                • Quothling 8 months ago
                  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.
                  • nurettin 8 months ago
                    You have a php project, and you want to use .net libraries.
                    • 8 months ago
                      • unnouinceput 8 months ago
                        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.
                        • hu3 8 months ago
                          Some might dislike your snark but obfuscation is a good use for this.
                      • 8 months ago