rapira/sdk

SDK for building on rapira: shared building blocks, testing utilities, and framework bridges

Maintainers

Package info

github.com/rapira-rs/sdk

Homepage

pkg:composer/rapira/sdk

Transparency log

Fund package maintenance!

Boosty

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.x-dev 2026-08-19 17:08 UTC

This package is not auto-updated.

Last update: 2026-08-19 17:10:22 UTC


README

Rapira SDK


An SDK for building PHP applications and tooling on top of rapira. It collects the shared building blocks that frameworks and their rapira bridges keep re-implementing — PSR-7 request factories, reusable wrappers and helpers, API clients, and testing utilities — under a single, framework-neutral package.

Everything lives under the Rapira\Testing namespace, organised by concern:

  • Common — framework-neutral core: binary provisioning (via dload) and the rapira serve process lifecycle.
  • Testo — a thin adapter that wires the core into the Testo test framework. It is the only framework bridge shipped at the moment; support for others may follow.

Its testing side provisions the rapira binary for a suite and starts a live rapira serve process around your test cases, so tests can exercise the application over a real socket instead of mocking the server.

Installation

composer require rapira/sdk

PHP Latest Version on Packagist License Total Downloads

The rapira binary itself is downloaded on demand via dload the first time a suite that needs it runs. Your project must have a dload.xml describing where to fetch it from (see the dload-fetch-tool skill or the dload documentation for how to register a software alias).

Usage with Testo

1. Provision the binary for a suite

Attach RunRapiraPlugin to the suite in testo.php. It downloads the rapira binary (once, if missing) and binds the application directory the server will run from.

use Rapira\Testing\Testo\RunRapiraPlugin;
use Testo\Application\Config\ApplicationConfig;
use Testo\Application\Config\Plugin\SuitePlugins;
use Testo\Application\Config\SuiteConfig;

return new ApplicationConfig(
    src: ['src'],
    suites: [
        new SuiteConfig(
            name: 'Integration',
            location: ['tests/Integration'],
            plugins: SuitePlugins::with(new RunRapiraPlugin(
                binary: __DIR__ . '/runtime/bin/rapira',
                workingDirectory: __DIR__ . '/tests/Integration/App',
                projectRoot: __DIR__,
            )),
        ),
    ],
);

2. Run the server around a test case

Annotate a test case with #[RunRapira]. Testo starts rapira serve before the case's tests and stops it afterwards.

use Rapira\Testing\Common\Mode;
use Rapira\Testing\Testo\Attribute\RunRapira;
use Testo\Attribute\Test;

#[RunRapira(mode: Mode::Worker, worker: 'worker.php', address: '127.0.0.1:8080')]
final class WorkerTest
{
    #[Test]
    public function respondsToRequests(): void
    {
        $response = file_get_contents('http://127.0.0.1:8080/');

        // ...assertions on $response
    }
}

RunRapira options:

Option Default Description
mode Mode::Worker Run mode passed as --mode (classic, worker, or dispatcher).
worker 'worker.php' Entrypoint script, absolute or relative to the working directory.
address '127.0.0.1:8080' Listen address (host:port, :port, or unix:<path>).
readyTimeout 5.0 Seconds to wait for the server to accept connections.