I just found out about FrankenPHP – it’s running really good so far. To make a benchmark test, i have to integrate my own PHP Zend Extension first, to see if it is viable to dig deeper into this. My PHP extension is running fine within my php-cli and php-fpm, but the FrankenPHP does not know anything of it so far.
I tried to inject my extension, when i am building the go binary – by extending one of the both flags, adding my extension module name:
CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build
Unfortunately i cannot find anything in the documentations – rather than doing a static build, which is nothing i need right now.
The extension itself is based on C and is using mpfr, so i may end up adding the functionality into my go module and expose it – with the upcoming challenge to call it in php, but i think that does not sound right at all. I’d prefer to compile it into the binary, just like opcache / gmp / .. – but those are native extensions.
2
Answers
As i mentioned in my original question before, there is no viable way and i have to figure it out myself apparently. Thank you very much for your help - i will reach out on this post, once i might get any new info on this problem. Otherwise, if you read this question in a couple of months or years, and there is no update, feel free to reach out to me, i might did not update this question with an answer. Good luck.
FrankenPHP currently doesn’t have built-in support for statically linking external PHP extensions like those in Zend. One approach you might consider is integrating your extension directly into the Go side of the application as a function, which you can then expose as an API for PHP to call.
Alternatively, you could attempt using a shared library (*.so file), though this requires additional setup, possibly involving dynamic loading through
dl()
or similar methods. If that’s not ideal, another option is to run your benchmark in an isolated PHP-FPM environment, where you know your Zend extension works, and then compare performance against FrankenPHP.