The Swoole team has open sourced TypePHP, a compiler that turns PHP source code into native machine code. Albert Chen noted on X that the release landed earlier than the October date the project had originally planned.
TypePHP is an ahead-of-time (AOT) compiler. It translates PHP into C++ and then into native machine code. It works differently from a bytecode cache or a virtual machine, which interpret opcodes while the program runs. TypePHP produces optimized native binaries that execute directly on the CPU instead.
The language keeps familiar PHP syntax and adds compile-time type information, allowing the compiler to emit fast, statically-typed C++ for hot paths. Dynamic PHP values, internal functions, reflection, and object metadata continue to interoperate with the Zend runtime through PHPX. User functions that have been compiled no longer execute as Zend opcodes.
TypePHP is written entirely in PHP and is fully self-hosting: the tpc compiler binary is built by compiling the compiler's own PHP source code with TypePHP. The bootstrap chain contains no C or C++ glue in the compiler itself. Documentation is available on the project's site at swoole.com/aot/en.
Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.