// the find
jordwalke/rehp
ReHp
rehp is a fork of js_of_ocaml that adds a PHP/Hack compilation backend for Reason/OCaml. The idea is to introduce an intermediate representation (Rehp) that sits between OCaml bytecode and the target language, making it easier to add backends beyond JavaScript. It's for teams running OCaml/Reason who need to interop with a PHP codebase without rewriting everything.
The intermediate IR approach is architecturally sound — instead of bolting PHP onto js_of_ocaml's JS-specific IR, they introduce Rehp as a language-agnostic layer, which is the right call. The module template system for controlling per-file output format is genuinely useful for integrating with PHP autoloaders that expect specific file layouts. Built by jordwalke (creator of Reason), so the OCaml/Reason toolchain integration is not an afterthought. The esy-based build means you can drop it into an existing project without fighting your package manager.
Last commit is February 2021 — this is effectively abandoned. The README's own 'Next Steps' section describes the project as needing substantial rework (rewrite PHP stubs by hand, remove JS-to-PHP transpiler, simplify Rehp), meaning what ships is explicitly not the intended final architecture. Only targets Hack (HHVM's PHP variant), not standard PHP, which narrows the audience considerably since most shops aren't running HHVM in 2024. There are no docs on what OCaml stdlib features actually work in the PHP backend versus silently producing broken output — the test suite covers OCaml-to-JS scenarios inherited from js_of_ocaml, not PHP-specific behavior.