Star RestPHP
Already starred? Check a public GitHub username below. This is not a GitHub login; only the username is remembered on this browser.
Appearance
Already starred? Check a public GitHub username below. This is not a GitHub login; only the username is remembered on this browser.
RestPHP is a modern, ultra-high-performance persistent application server and runtime for PHP, written in Rust.
Runtime modes: RestPHP serves plain PHP and conventional framework entrypoints with a complete PHP request lifecycle, or runs boot-once callback workers through --persistent-worker. The Laravel adapter uses Octane's request sandbox and lifecycle listeners.
For decades, the standard way to deploy PHP applications has been Nginx + PHP-FPM (FastCGI) or Apache with mod_php.
In this model:
Even with OPcache, 70% to 80% of request time is spent re-bootstrapping the framework, severely limiting raw throughput to a few hundred requests per second.
In recent years, tools like FrankenPHP and RoadRunner introduced persistent workers to PHP by writing servers in Go:
However, writing a persistent PHP runtime in Go comes with fundamental architectural penalties:
cgo Stack-Switching Tax Go has its own runtime and lightweight segmented stacks (goroutines). Whenever Go calls C (the Zend Engine API), it must switch to a standard POSIX thread stack. This cgo transition costs ~60ns per invocation. Under 50,000 req/s, this context-switching overhead wastes substantial CPU cycles.
Go has an active Garbage Collector (Stop-The-World concurrent mark-sweep), and PHP has its own cyclic Garbage Collector. When running high traffic, the host Go runtime triggers GC pauses, causing jitter and degrading p99 tail latency.
RestPHP was designed from the ground up to solve these problems by embedding the Zend Engine directly into Rust:
extern "C"). Zero stack switches, zero glue overhead.