Download the PHP package phpdot/http-middleware without Composer
On this page you can find all versions of the php package phpdot/http-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package http-middleware
phpdot/http-middleware
PSR-15 middlewares for PHPdot. Each is a small, framework-agnostic middleware that plugs into any PSR-15 pipeline.
| Class | Does |
|---|---|
Pipeline |
The PSR-15 dispatcher: runs a middleware list (outermost first) around a final handler. Itself a RequestHandlerInterface, so pipelines nest and any transport serves one directly. Stateless per call — one shared instance is coroutine-safe under Swoole. |
JsonBodyMiddleware |
Decodes application/json request bodies into the request's parsed body; rejects malformed JSON with 400. |
AjaxMiddleware |
Restricts a route to script-issued requests; a browser navigating to it gets a 404. A convenience, not a security control — the signals are client-supplied. |
Table of Contents
- Requirements
- Installation
- Usage
- Testing
- License
Requirements
| Requirement | Constraint |
|---|---|
| PHP | >= 8.5 |
phpdot/contracts |
^0.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
Usage
Pipeline
Compose middlewares around a final handler; the pipeline is itself a PSR-15 handler:
Middlewares run in list order — the first is outermost. Each may short-circuit by returning a
response without delegating; when every middleware delegates, the final handler runs. Pipelines
nest: a Pipeline is a valid final handler for another Pipeline.
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:
Testing
License
MIT.
This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.
All versions of http-middleware with dependencies
phpdot/contracts Version ^0.5
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0