A Rust application server for PHP.
Website · Documentation · Quickstart · Releases
Rapira loads non-thread-safe (NTS) PHP into the server process through the PHP embed SAPI and calls the interpreter directly. There is no FastCGI, no socket between Rapira and PHP, and no serialization for each request. The maintainers of RoadRunner develop Rapira.
Rapira serves:
- HTTP/1.1 requests and static files.
- Unary gRPC, gRPC-Web, and Connect calls on one listener.
- Prometheus metrics and the
/livezand/readyzhealth probes.
Rapira has three execution modes:
- Classic runs the front controller for each request, as
php-fpmdoes. The application does not need code changes. - Worker initializes the application one time for each worker and calls a handler for each request.
- Dispatcher gives each request to the application as an object:
Rapira\Http\Exchangefor HTTP,Rapira\Grpc\UnaryCallfor gRPC. This is the default mode.
Download a build for PHP 8.4, 8.5, or 8.6 from the download page. Each build includes NTS PHP. Rapira runs on Linux and macOS. The Windows builds are for local development only. See the installation guide.
To run an existing application in Classic mode, create rapira.toml next to the public directory:
[http]
listen = "127.0.0.1:8000"
[http.pool]
entrypoint = "public/index.php"
mode = "classic"Start the server:
rapira serve rapira.tomlThe builds include a fixed set of PHP extensions. For other extensions, build an NTS libphp. You do not need to rebuild Rapira.
The ghcr.io/rapira-rs/rapira:php8.4, php8.5, and php8.6 images contain Rapira, NTS PHP, and common PHP extensions on Debian Trixie. There is no latest tag. The image starts rapira serve /app/rapira.toml:
FROM ghcr.io/rapira-rs/rapira:php8.5
COPY . /appSee the Docker guide and the framework guides for Symfony, Laravel, and Yii 3.
- rapira: the Rust server core and its integration with the PHP embed SAPI.
- contract: the functions, classes, interfaces, and exceptions that Rapira gives to PHP code, as the
rapira/contractComposer package. Rapira provides the implementations. - sdk-php: the
rapira/httpPSR-7 request factories and therapira/testingtest utilities. - yii-runner-rapira: the Yii 3 application runner for all three modes.
- docker: the
ghcr.io/rapira-rs/phpimages withlibphp.so, NTS and ZTS, on Debian and Alpine. The Rapira image uses the NTS Debian image as its base. - rapira-rs.github.io: the source of the rapira.rs documentation site.
Open PHP SDK issues in the sdk-php issue tracker. Open all other issues in the Rapira issue tracker. See the contribution guide for build and test instructions.