An experimental PHP runtime written in Rust — grown almost entirely through AI-assisted development.
rphp is a from-scratch reimplementation of the PHP language and runtime in Rust. It compiles PHP to a
register-based bytecode and executes it on its own VM, aiming for byte-for-byte compatibility with the
official PHP engine's semantics (targeting PHP 8.5).
⚠️ This is a research project, not a production runtime. It is a place to explore two questions at once — how far can an AI coding agent carry a large, unglamorous compatibility-driven migration? and what does PHP look like if you rebuild it on a modern Rust foundation and get to add features along the way? Do not run it in production.
There is a growing wave of "rewrite the incumbent in Rust" projects — Bun moving its JavaScript transpiler internals to Rust, the React Compiler being ported to Rust, and plenty of others. They share a shape: take a mature, battle-tested runtime or toolchain, and rebuild its guts on a faster, safer foundation without breaking the ecosystem that depends on it.
rphp is that experiment for PHP, with two twists:
-
It is AI-first. The overwhelming majority of the compiler, VM, and extension code here was written by an AI coding agent working against a tight compatibility harness — the official php-src test suite and the Zend engine's own opcode dumps — rather than by a human hand-porting file by file. The interesting result is not just "PHP in Rust" but how it got there: a feedback loop where the agent diffs its output against real PHP, finds the divergence, reads php-src to understand the true behavior, and closes the gap.
-
Compatibility is the floor, not the ceiling. Because it is a clean-room implementation on a modern base,
rphpis free to add things stock PHP does not have — a fork-per-request server model, an integer JIT prototype, async I/O under the hood — while still running unmodified PHP applications.
- A full register VM with one Zend-parity handler per opcode, plus a compiler and optimizer that emit
opcodes closely matching what
opcacheproduces. - Real-world frameworks run end-to-end. The Symfony Demo application — Doctrine ORM, Twig, API Platform, and PDO talking to PostgreSQL — boots and serves requests.
- A production-shaped server model.
rphp-webboots the application once, pauses at a checkpoint, and forks per request to serve the Symfony demo. - A broad slice of the standard library and extensions, each as its own crate:
standard,spl,pcre,date,hash,pdo(mysql / pgsql / sqlite),reflection,session,simplexml,phar,zlib,random,tokenizer, and more. - Measured against the real thing. Every change is gated for zero regressions against the php-src test suite and the Zend engine test suite.
crates/
rphp-compiler/ PHP source → register bytecode + optimizer passes
rphp-vm/ the register VM, GC, runtime, and native ABI
rphp-bytecode/ bytecode / opcode definitions
rphp-jit/ experimental integer JIT (Cranelift, off by default)
rphp-cli/ the `rphp` CLI binary
rphp-web/ the `rphp-web` fork-per-request HTTP server
rphp-ext-*/ one crate per PHP extension (standard, spl, pdo, pcre, …)
docs/ design notes (register VM rewrite, optimizer, PDO, …)
tests/ compatibility test harness
php-src/ official PHP source, as a submodule (the reference)
Requires a recent Rust toolchain (edition 2024). The project uses git submodules for the php-src reference.
git submodule update --init --recursive
# Build the CLI
cargo build --release -p rphp
# Run a PHP script
./target/release/rphp path/to/script.php
# Run the fork-per-request web server
cargo run --release -p rphp-webrphp is an actively-evolving experiment. It does not implement all of PHP, some extensions are partial,
and the JIT is a prototype that is currently disabled by default. Numbers, coverage, and the feature set
change frequently. The goal is exploration and learning — treat it accordingly.
Licensed under the MIT License.