Search by

spiral / rapira-bridge

roxblnfk

Rapira application server integration for Spiral Framework

Package info

github.com/spiral/rapira-bridge

Homepage

Chat

Documentation

pkg:composer/spiral/rapira-bridge

Fund package maintenance!

spiral

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.10.0 2026-12-05 16:26 UTC

This package is auto-updated.

Last update: 2026-12-05 16:34:37 UTC


README

Spiral Framework

Rapira application server integration for Spiral Framework

Documentation Sponsor

Psalm Level Type Coverage Codecov Mutation testing badge


Runs a Spiral application under Rapira, the PHP application server written in Rust.

The bridge serves HTTP in Rapira's dispatcher mode: one long-lived PHP process takes request/response exchanges from the host, runs each through the Spiral HTTP pipeline and writes the response back.

Get Started

Installation

composer require spiral/rapira-bridge

PHP Latest Version on Packagist License Total Downloads

The bridge needs Spiral Framework 3.15.6+ and a PSR-7 and PSR-17 implementation, e.g. spiral/nyholm-bridge.

Usage

Add the HTTP bootloader to the application kernel:

use Spiral\RapiraBridge\Bootloader as RapiraBridge;

class Kernel extends \Spiral\Framework\Kernel
{
    protected const LOAD = [
        // ...
        RapiraBridge\HttpBootloader::class,
    ];
}

The entry script is the usual Spiral one; the kernel picks the dispatcher from the mode the host launched the process in:

// app.php
use App\Application\Kernel;

require __DIR__ . '/vendor/autoload.php';

Kernel::create(directories: ['root' => __DIR__])->run()?->serve();

Point the Rapira pool at it in dispatcher mode:

# rapira.toml
[http]
listen = "0.0.0.0:8080"

[http.pool]
entrypoint = "app.php"
mode = "dispatcher"
rapira serve

What the bridge does

  • RapiraBootloader exposes the runtime to the container: Rapira\Mode, Rapira\Dispatcher and Rapira\Http\HttpDispatcher. When the pool hands the process a dispatcher no bootloader serves, it fails with a hint which bootloader is missing.
  • HttpBootloader registers the HTTP dispatcher. It hydrates a PSR-7 request from each exchange with rapira/http, runs it through Spiral\Http\Http and writes the response into the exchange: a small body in one write, a large one streamed in chunks.
  • Requests are served one at a time, and the application is finalized after each of them.
  • A failure in the handler, or in the response body before the head went out, is reported to the exception handler and answered with 500 — with the error details outside the production environment. A failure after the head went out leaves the response unfinished, and the host breaks the connection.
  • A response to HEAD declares the length of the body a GET would get, without sending it — when the body knows its size or the application declared Content-Length.

Limitations

  • Only the dispatcher mode is served. The worker mode is reported as unsupported; the classic mode is a plain SAPI request and is left to other dispatchers.
  • The kernel serves with the first dispatcher that accepts the process. Under Rapira PHP_SAPI is not cli, so a SAPI dispatcher (spiral/sapi-bridge) loaded before HttpBootloader takes the process over: keep it after, or out of a kernel that runs under Rapira.

Testing

composer test             # all suites, the acceptance one included
composer test:unit
composer test:feature     # the application against a scripted Rapira runtime
composer test:acceptance  # the application under the real `rapira` binary, downloaded on demand

Static analysis, mutation testing and code style run from isolated installs in vendor-bin:

composer bin all install
composer psalm
composer infect
composer cs:fix