PHP 8.x on the Zipp register VM
Zipp compiles PHP 8.x templates, scripts and Composer frameworks straight to its shared register bytecode and runs them on the same VM as JavaScript, TypeScript, Python and Rust — with no external PHP binary, no PHP-to-JS transpilation, an HTTP/1.1 Worker Mode server, and a browser WebAssembly build.
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.
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.phpLanguage 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,gotowithtry/finallyunwind, generators (yield,yield from), classes/interfaces/traits, constructor property promotion,readonlyand anonymous classes, typed class constants, PHP 8.4 parenthesis-lessnew Foo()->bar(), asymmetric visibility, property hooks, Unit and Backedenums, 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, lightweightintl, crypto (hash,hash_hmac, OS-seededrandom_bytes/random_int,password_hash/password_verify),DateTime/DateTimeImmutable,PDO/mysqliSQL bridges, streams andspl_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.
| Workload | ZIPP | PHP 8.4.15 | Comparison |
|---|---|---|---|
bench.php total (compute, array & OOP) | 3.0 ms | 53.4 ms | 17.8× faster |
Cold CLI empty.php (median of 7) | 13.5 ms | 45.5 ms | 3.37× faster |
| Cold CLI Slim 4.15 multi-route | 39.7 ms | 59.9 ms | 1.51× faster |
| Cold CLI CakePHP 5.4 multi-route | 67.0 ms | 96.2 ms | 1.44× faster |
| Cold CLI Laravel 11.51 multi-route | 67.6 ms | 79.7 ms | 1.18× faster |
| HTTP Worker Mode Slim 4.15 (8× concurrency) | 1,712 req/s | 355 req/s (php -S) | 2.67 ms/req seq |
| HTTP Worker Mode CakePHP 5.4 (8× concurrency) | 2,233 req/s | 356 req/s (php -S) | 3.32 ms/req seq |
| HTTP Worker Mode Laravel 11.51 (8× concurrency) | 1,409 req/s | 298 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.