phpdot/http-middleware

PSR-15 middlewares for PHPdot.

Maintainers

Package info

github.com/phpdot/http-middleware

Issues

pkg:composer/phpdot/http-middleware

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-07-17 23:14 UTC

This package is auto-updated.

Last update: 2026-07-18 03:24:49 UTC


README

PSR-15 middlewares for PHPdot. Each is a small, framework-agnostic middleware that plugs into any PSR-15 pipeline. Currently: JsonBodyMiddleware, which decodes JSON request bodies into the request's parsed body.

Table of Contents

Requirements

Requirement Constraint
PHP >= 8.5
psr/http-factory ^1.0
psr/http-message ^2.0
psr/http-server-handler ^1.0
psr/http-server-middleware ^1.0

Bring any PSR-7/PSR-17 implementation (for example phpdot/http).

Installation

composer require phpdot/http-middleware

Usage

JsonBodyMiddleware

For requests with a application/json content type, it decodes the body and exposes it via getParsedBody(); a malformed body returns a 400 with a JSON error, and non-JSON or empty bodies pass straight through. Construct it with your PSR-17 response and stream factories and add it to the pipeline:

use PHPdot\HttpMiddleware\JsonBodyMiddleware;

$middleware = new JsonBodyMiddleware($responseFactory, $streamFactory);

// In your PSR-15 pipeline, before handlers that read getParsedBody()
$app->pipe($middleware);
// Downstream, the decoded body is available as the parsed body:
$data = $request->getParsedBody();

Testing

composer install
composer test        # PHPUnit
composer analyse     # PHPStan, level max + strict rules
composer cs-check    # PHP-CS-Fixer
composer check       # All three

License

MIT.

This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.