How PHP reaches the VM

Zipp's pure-Rust parser (zipp-phpparse, #![forbid(unsafe_code)], zero dependencies) lexes and parses dual-mode HTML and PHP 8.x syntax into an AST. The frontend resolves namespaces and use imports, analyzes scopes, and lowers directly into Zipp's register bytecode, sharing the same frame stack, garbage collector and native JIT as JavaScript.

PHP semantics live in a memoized and disk-cached runtime seed (__zipp_php): exact 64-bit integers (unboxed in Value for ±2^46, auto-promoting to float on overflow), binary-safe byte strings (strlen("café") === 5, mb_strlen("café") === 4), ordered-map arrays with O(1) sticky-shared copy-on-write and zero-copy foreach, &$x references, plain-object OOP instances, and lazily materialized Reflection, SPL, DateTime and Intl builtins.

Run PHP scripts and HTTP servers natively
zipp php app.php [args...]
zipp app.php [args...]

# Shared-nothing HTTP/1.1 SAPI server with in-process OPcache
zipp php -S 127.0.0.1:8000 -t examples/php/backend examples/php/backend/index.php

# Long-lived Worker Mode (boot once, serve requests on a warm VM)
zipp php --worker -S 127.0.0.1:8000 -t examples/php/backend examples/php/backend/worker.php

Language and framework coverage

The PHP frontend is tested byte-for-byte against native PHP 8.4.15 with Composer 2 (vendor/autoload.php) across real Laravel 11 (2,512 vendor files), Slim 4 (178 vendor files) and CakePHP 5 (1,048 vendor files), in both CLI invocations and live HTTP/1.1 Worker Mode.

  • Dual-mode HTML templates: inline HTML outside <?php ... ?>, <?= ... ?>, alternative control syntax (if (...): ... endif;), heredoc/nowdoc, string interpolation and nested output buffering (ob_start..ob_get_clean).
  • Modern PHP 8.1–8.4 features: namespaces and group use, closures (use ($a, &$b), Closure::bind), arrow functions, named and variadic arguments, first-class callables, match, destructuring, goto with try/finally unwind, generators (yield, yield from), classes/interfaces/traits, constructor property promotion, readonly and anonymous classes, typed class constants, PHP 8.4 parenthesis-less new Foo()->bar(), asymmetric visibility, property hooks, Unit and Backed enums, late static binding, magic methods, attributes (#[...]) and full Reflection.
  • Backend standard library: $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES, $_REQUEST, $_ENV, $_SESSION, php://input, php://temp, header(), http_response_code(), setcookie(), session_*(), JSON, PCRE (possessive quantifiers, recursion, (*SKIP)(*F), branch reset groups and Unicode classes), mb_*, ctype_*, SPL iterators and containers, lightweight intl, crypto (hash, hash_hmac, OS-seeded random_bytes/random_int, password_hash/password_verify), DateTime/DateTimeImmutable, PDO/mysqli SQL bridges, streams and spl_autoload_register.

Performance and Worker Mode

Zipp lowers PHP hot paths onto its existing register VM and selective native x86-64 JIT without adding PHP-specific opcodes. Guarded JS-Number companion functions and pure-int OOP methods compile natively through Tier-A and Tier-C while generic 64-bit BigInt bodies stay on the zero-overhead interpreter, falling back with 100% parity on overflow. A persistent single-file disk OPcache pack (ZPO2) validates included .php files by (mtime_nanos, file_len) metadata checks with lazy blob decode.

Windows x86-64 release build vs local native PHP 8.4.15 (100% byte-for-byte parity; see docs/PHP.md)
WorkloadZIPPPHP 8.4.15Comparison
bench.php total (compute, array & OOP)3.0 ms53.4 ms17.8× faster
Cold CLI empty.php (median of 7)13.5 ms45.5 ms3.37× faster
Cold CLI Slim 4.15 multi-route39.7 ms59.9 ms1.51× faster
Cold CLI CakePHP 5.4 multi-route67.0 ms96.2 ms1.44× faster
Cold CLI Laravel 11.51 multi-route67.6 ms79.7 ms1.18× faster
HTTP Worker Mode Slim 4.15 (8× concurrency)1,712 req/s355 req/s (php -S)2.67 ms/req seq
HTTP Worker Mode CakePHP 5.4 (8× concurrency)2,233 req/s356 req/s (php -S)3.32 ms/req seq
HTTP Worker Mode Laravel 11.51 (8× concurrency)1,409 req/s298 req/s (php -S)5.65 ms/req seq

PHP in WebAssembly

Published from v0.0.37 as zipp-0.0.37-javascript-php.wasm (6,038,525 bytes raw, 1,480,745 bytes after Brotli-11), the browser build compiles out native filesystem and process-environment access under safe-sandbox and replaces them with a caller-supplied virtual filesystem.

Browser and Worker hosts drive PHP web applications through PhpApp (supporting both per-request SAPI dispatch and persistent Worker Mode) and attach external SQL databases such as XDB SQLite via composable addAppBridge("sql", bridge): PDO and mysqli route queries through host-owned app.sql.* capabilities while sharing the guest VM's instruction budget.