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.