Live data from Hacker News

Show HN: FrankenPHP, an app server for PHP written in Go

frankenphp.dev

81–90 of 93 posts

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#82
post #77
post #69

Earlier quoted context omitted.

Just some experiences I've had putting large PHP frameworks into strange spaces: 1. Most PHP frameworks are designed to have all state destroyed at the end of a request. I was trying to integrate a commercial ecommerce framework with something like Road Runner and another one that I forget the name of. The framework had a DI system which provides each module with its own private instance of all injected instances, so…

Re (1) how feasible would it be to basically teach the PHP VM the equivalent of fork() so you can do all the booting once but still have a fresh copy of the end result on each request? I mean, it's not going to be as cheap as getting the thing to actually run in a loop, but it might be enough cheaper than the booting process to be worthwhile.

It's a cool idea but I haven't explored this in detail so I don't have a good answer. I haven't touched PHP in 2 years but they have a new feature which might achieve some of those design goals you mentioned:

https://www.php.net/manual/en/opcache.preloading.php

> preload.php is an arbitrary file that will run once at server startup (PHP-FPM, mod_php, etc.) and load code into persistent memory.

It's interesting to me, because in a big ecomm framework we were getting 80ms PHP page loads, with something like preload it could probably be moved down to 25 or 30ms.

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#83
post #36

What is the difference between this and Roadrunner? It seems to do the same stuff. https://github.com/roadrunner-server/roadrunner

The approach isn't the same: Roadrunner executes php-cli and connects it to its web server through GRPC; FrankenPHP uses an ad-hoc SAPI, it is more like Apache's mod_php, the Go code uses the PHP interpreter as a library, it's all in the same process. RoadRunner only has a worker mode, and can only work with compatible apps; FrankenPHP has a "standard" mode compatible with all existing applications, and a worker mode…

Hey @kdunglas :) Nice project :) I just wanted to add a few notes:

> Roadrunner executes php-cli and connects it to its web server through GRPC;

RR communicates with the PHP process via pipes (stdin/out/err) via our protocol (similar to the IP protocol, we also have a tcp/unix-socket options and shared memory is coming soon). The RR server itself then has various options to connect to the world:

- gRPC (w/o the need to install the `gRPC-php` extension), HTTP (with a lot of different middleware), HTTPS, fCGI. - Queues: kafka, rabbitmq, sqs, beanstalk, nats (with like priorities and so on) - KV/noSQL: memcached, redis, boltdb, memory. - Workflows: Temporal.

I might forget smt, but the main idea is to have a very extensible server. With very little knowledge about Go, you may extend it with your plugins and build your RR binary. Or even embed the RR server into your Go application (https://github.com/roadrunner-server/roadrunner/tree/master/...).

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#84

Earlier quoted context omitted.

When do things ever "just compile"? I assume the Docker image is because this is a pre-alpha and the docker image ensures that no one needs to go through hours of dependency/config hell because the docker image is set up with everything necessary already, letting you focus on alpha-testing this and reporting bugs.

typically I find CMake would do this, or Make, to verify dependencies. Coupled with a packaging system, like debian gives you, this is all pretty straightforward. I ran into this yesterday, and turns out I don't want to install docker just to build a program...

Except of course in this case that's not what you'd be doing. You'd be installing Docker to help beta-test a program, not "just build a program". If you want to help an open source project succeed, having to install Docker is kind of a trivial cost. If you want to use this... probably not a good idea, it's extremely not ready for general use =)

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#85
post #62
post #49

Earlier quoted context omitted.

That's interesting, in my experience php-fpm has been very dependable even in demanding situations where we migrate over to new backends without missing a request. PHP applications can be a different story, but php-fpm provides enough knobs to restart problematic applications on demand. It's probably that last part of a PHP stack I'd want to replace. Debugging application servers in production comes with its own set…

PHP-FPM has a ton of debugging, logging, and performance-tuning options, but in most popular distros most of them are disabled by default. If you get a Dockerfile from somewhere and just tweak pm.max_children, you're likely to end up with all the helpful stuff commented out.

Not reading the manual for software your production environment is built on? Surely you are joking.

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#86
This is amazing, and way more advanced than what was there. Going to definitely use it on the next project.

Previously, there was https://github.com/deuill/go-php which was PHP5 and PHP7, but you needed to build PHP with ZTS. I had to forke it to focus on PHP5 and bring some improvements - my primary goal was to port some legacy PHP over iteratively via the Strangler pattern. If it can still be useful to some, the fork is here - https://github.com/borancar/go-php

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#87
post #79

Earlier quoted context omitted.

Removing php-fpm + nginx from a container sounds AMAZING to me. If I can just have one thing in a container (plus a code base), that would be a LOT simpler than: nginx, php-fpm, some init system, and the convoluted configuration needed to get logs out via Docker's logging mechanism.

What about having 1 Dockerfile but run php-fpm in 1 container with nginx in a 2nd container? This pattern is common for background workers too, such as running gunicorn + celery in separate containers (Python tools) but the same image is used for both. You can change the CMD at runtime by overwriting it (for example the `command` property in Docker Compose and Kubernetes). This avoids needing to hack around things at…

Very doable. Although on systems like Fly where you attempt to build one container to run an app, it’s a bit overkill.

What I dislike most about php-fpm is the logging mechanism (or lack thereof). You need to configure it to capture stderr from php processes and then have PHP send logs to stderr. Sorta wonky.

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#88
I was in the conference (20221014, afup 2022), where frankenphp was released live. The conference was really interesting and answer many (if not all) of the questions raised in comments.

I'v checked and unfortunately the video recording is not available for now, I will post a link here as son as available.

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#89
post #79

Earlier quoted context omitted.

What about having 1 Dockerfile but run php-fpm in 1 container with nginx in a 2nd container? This pattern is common for background workers too, such as running gunicorn + celery in separate containers (Python tools) but the same image is used for both. You can change the CMD at runtime by overwriting it (for example the `command` property in Docker Compose and Kubernetes). This avoids needing to hack around things at…

Very doable. Although on systems like Fly where you attempt to build one container to run an app, it’s a bit overkill. What I dislike most about php-fpm is the logging mechanism (or lack thereof). You need to configure it to capture stderr from php processes and then have PHP send logs to stderr. Sorta wonky.

> Although on systems like Fly where you attempt to build one container to run an app, it’s a bit overkill.

I never used Fly but hosting a web + worker combo is common in a lot of tech stacks and with Docker it's really common to use 1 image to drive both containers with a different command. If Fly doesn't support that then I'd suggest hosting things elsewhere. Docker Compose and Kubernetes supports this no problem, it's a really basic / day 1 use case.

Re: Show HN: FrankenPHP, an app server for PHP written in Go

#90
post #6

I've been watching how Go and Rust tooling has been finding its way into the JavaScript ecosystem. I've been out of the PHP realm for about 10 years but I did find RoadRunner for PHP at one point. That's also an app server written in Go I believe. I wonder how this compares.

Don't forget Zig, with Bun.

Ah yes. I've had my eye on that as well!
Post reply on HN