gilsegura / psr-server
The component provides infrastructure for building PSR-15 request handlers and middleware pipelines, plus a typed response factory for serializable payloads.
1.1.0
2026-06-13 11:50 UTC
Requires
- php: ^8.4
- gilsegura/serializer: ^1.0
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^13.1
- rector/rector: ^2.4
README
Minimal, framework-agnostic PSR-15 server primitives: a middleware runner, a request handler and a response factory. It gives you the small pieces needed to run a request through a middleware pipeline and build a response, without pulling in a full framework.
Installation
composer require gilsegura/psr-server
Middleware pipeline
MiddlewareRunner— takes a variadic list of PSR-15 middlewares and runs a request through them in order, delegating to a terminalRequestHandlerInterfaceat the end. It is the engine behind a request pipeline.StackMiddleware— adapts the run to the PSR-15 stack model, advancing to the next middleware in the chain.RequestHandler— aRequestHandlerInterfacethat wraps the runner and a terminal handler, so the whole pipeline is itself a single PSR-15 handler.
Responses
ResponseFactory— an invokable that builds a PSR-7 response from a status and body.Status— anint-backed enum of HTTP status codes (OK,CREATED,NO_CONTENT,BAD_REQUEST,UNAUTHORIZED, …), so status codes are referenced by name instead of magic numbers.
License
MIT. See LICENSE.