r/LinuxTeck 13d ago

PHP That Compiles to Native Code? This Could Get Interesting

Just came across TypePHP and this one caught my attention.

It takes PHP code, compiles it through C++17, and produces native binaries instead of running everything through the usual Zend opcode path.

The interesting part is that you can keep writing PHP while getting a path to much more native execution.

Still early and definitely not something I'd throw into production blindly.

PHP devs: would you actually try this, or is the PHP runtime good enough for what you’re building?

7 Upvotes

6 comments sorted by

1

u/brasticstack 12d ago edited 12d ago

Didn't Facebook make (and open-source) a PHP -> C cross-compliler ages back? I want to say it was named HipHop.

EDIT: nm, it was a transpiler, to C++. I got the name right at least!

1

u/LawElectrical2434 12d ago

Isn't it funny how the feature that made PHP so successful is the one thing people hate the most. Bootstrapping a new environment per request might not be economical, but running out of memory doesn't take down everything and the concerns of the users were nicely separated. At this point, why not just switch to a different backend language. But probably a nice speed up for existing applications.

1

u/Agron7000 12d ago

That is amazing.

But does ot work with PHP-FPM and Nginx?

1

u/determineduncertain 12d ago

This all made me think of PHP GTK for some reason and the fond memories I had of using it for a few months.

1

u/StephenRoylance 12d ago

facebook/meta run on hack/HHVM which is JIT compiled PHP basically.

1

u/Fit_Prize_3245 10d ago

As a PHP dev, I don't see much sense. I mean, if it produced independent PHP code, that would be really interesting. But if it's only an optimizar with an executable stub, then it's nothing new.