Hacker News new | ask | show | jobs
by awirth 3269 days ago
If you want to use an existing toolchain, you could use HPHPc (the predecessor to HHVM, which transpiled PHP to C code) and emscripten to translate from C to Javascript. It would probably require some mucking around at the emscripten layer though to get all the packages linking properly, because HPHPc has a non-trivial number of (non-optional) runtime deps for supporting all of the various php modules. You should just be able to compile them separately with emscripten into a prefix (e.g. don't use emscripten ports, which I've had a terrible time with) but YMMV.

I dockerized a working version of HPHPc (which is quite difficult to set up due to bitrot) at https://github.com/allanlw/hphpc-docker if you want to play around with the compiler. I might try to take a shot at passing it through emscripten later.

1 comments

That's really cool, and seems like it would take a lot of the hassle of "understanding" PHP out of the equation. Nicely done!