Search by

rapira / http

roxblnfk

PSR-7 server-request factories for every Rapira run mode

Package info

github.com/rapira-rs/http-php

pkg:composer/rapira/http

Fund package maintenance!

Boosty

rapira-rs

Statistics

Installs: 411

Dependents: 2

Suggesters: 0

Stars: 1

0.1.6 2026-10-08 11:39 UTC

This package is auto-updated.

Last update: 2026-10-08 11:40:54 UTC


README

rapira/http


Important

🪞 This is a read-only mirror.

Active development lives in rapira-rs/sdk-php under packages/http/. This repository is automatically synchronized from there on every release.

File issues and pull requests in the main monorepo, not here.

About

Builds a PSR-7 ServerRequestInterface from the shape Rapira hands your worker, with one factory per run mode:

  • SapiRequestFactory — hydrates the request from the PHP superglobals ($_SERVER, $_GET, $_POST, $_FILES), the shape Rapira exposes in classic and worker modes.
  • DispatcherRequestFactory — hydrates it from the Rapira\Http\Exchange the host delivers in dispatcher mode, without touching the superglobals.

Both take PSR-17 factories, so you keep your project's own PSR-7 implementation.

Install

composer require rapira/http

PHP Latest Version on Packagist License Total Downloads

Usage

Classic / worker mode — from the SAPI environment:

use Rapira\Sdk\Http\SapiRequestFactory;

$factory = new SapiRequestFactory(
    $serverRequestFactory, // Psr\Http\Message\ServerRequestFactoryInterface
    $uriFactory,           // Psr\Http\Message\UriFactoryInterface
    $uploadedFileFactory,  // Psr\Http\Message\UploadedFileFactoryInterface
    $streamFactory,        // Psr\Http\Message\StreamFactoryInterface
);

$request = $factory->create();

Dispatcher mode — from the exchange the host delivers:

use Rapira\Sdk\Http\DispatcherRequestFactory;

$factory = new DispatcherRequestFactory(
    $serverRequestFactory,
    $uploadedFileFactory,
    $streamFactory,
);

$request = $factory->create($exchange); // Rapira\Http\Exchange

Dispatcher mode

Dispatcher mode is built for async code, so DispatcherRequestFactory builds each request from the exchange alone: it never reads or writes the superglobals and keeps no state between requests. Code that needs $_SERVER, $_GET and the rest belongs in worker mode.