RPHP is an independent, experimental PHP-compatible runtime written in Rust. It has its own lexer, parser, bytecode compiler, virtual machine, and optional native execution tiers. RPHP does not embed PHP, preserve the Zend C ABI, or copy the Zend Engine architecture.
Warning
RPHP is pre-alpha. It implements a tested subset of PHP, contains substantial unsafe VM/JIT code, and has not been security-hardened. Do not run untrusted PHP code or use RPHP in production.
The tested subset currently covers scalar expressions and control flow, functions and closures, arrays and copy-on-write behavior, classes, inheritance, interfaces, traits, exceptions, generators, type declarations, namespaces, selected reflection behavior, JSON, regular expressions, and a growing standard-library surface. Some streams, file operations, structured coroutines and experimental generic types are opt-in Cargo features. The default build includes native execution for proven hot regions on the two primary targets below.
RPHP is not yet a drop-in replacement for PHP. Major gaps include complete language and standard-library compatibility, most extensions, broad Composer and framework support beyond the pinned compatibility gates, web SAPIs, databases, Redis, cURL, production-grade cycle collection, and broad JIT coverage. See the compatibility status for the current support contract.
CI tests the baseline runtime and native execution on these primary targets:
| Target | Baseline runtime | Default native JIT |
|---|---|---|
| macOS / AArch64 | Yes | Yes |
| Linux / x86-64 | Yes | Yes |
Other Rust targets may compile, but are not supported by the pre-alpha CI contract. The project currently makes no minimum operating-system version guarantee.
Install Rustup and clone the repository. Rustup will use
the toolchain pinned in rust-toolchain.toml.
cargo build --profile max-perf
./target/max-perf/rphp -r 'echo "Hello from RPHP\n";'
./target/max-perf/rphp example.phpA source file or standard input must contain a PHP opening tag. Code passed to
-r does not require one.
printf '<?php echo 6 * 7;' | ./target/max-perf/rphp
./target/max-perf/rphp --help
./target/max-perf/rphp --versionFeatures are selected at compile time. The resulting binary automatically uses an enabled optimization when the current target and program region qualify.
# Structured, cooperative coroutines and their PHP API
cargo build --profile max-perf --features coroutines
# Bound-erased experimental generic types
cargo build --profile max-perf --features php-generics-erased
# Reified experimental generic types
cargo build --profile max-perf --features php-generics-reifiedThe default binary automatically lowers qualifying hot regions to native code
on macOS/AArch64 and Linux/x86-64. Set RPHP_DISABLE_JIT=1 to retain the same
binary but force the typed executor, or build an explicit typed-only binary
with --no-default-features --features quick-loops. Live executable mappings
are capped at 16 MiB by default; RPHP_JIT_CODE_LIMIT_BYTES may lower that
budget or raise it up to the hard 1 GiB ceiling. The historical
jit-prototype Cargo feature remains available for explicit no-default build
matrices.
The generic syntax is an RPHP experiment and is disabled in a default build. An all-features build contains both generic runtime capabilities for differential testing. The coroutine API and its current limitations are described in the runtime roadmap.
- Architecture
- Active engineering roadmap
- Compatibility status
- Compatibility roadmap
- Execution and performance roadmap
- Specialized agent goal contract
- Runtime architecture engineering log
- Combined performance/JIT/compatibility engineering log
- Benchmark methodology
- Unsafe-code policy
- Code provenance policy
Repository benchmarks measure specific program shapes inside RPHP's currently supported region. They do not represent the performance of all PHP applications. Every publishable result must identify the exact commit, hardware and operating system, PHP version and JIT configuration, RPHP feature flags, warm-up, repetitions, aggregation method, and benchmark source. See the benchmark methodology.
Read CONTRIBUTING.md before sending a change. In particular, all contributions must be original or carry a compatible, disclosed license; do not copy source from PHP/Zend, TA-Lib, or another implementation.
Security issues must not be filed as public bug reports. Follow SECURITY.md. RPHP's dependencies and their declared licenses are listed in THIRD_PARTY.md.
RPHP is dual-licensed under the MIT License or the Apache License, Version 2.0, at your option.