pushinbr / pam-http-psr
PSR-7, PSR-15 and PSR-17 implementations for Pam.
Requires
- php: ^8.4
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Bring PSR-7, PSR-15 and PSR-17 software to PAM HTTP.
Messages, factories and a middleware pipeline built on the official PHP-FIG interfaces, at an explicit interoperability boundary.
Install · Quick example · What is inside · Docs · Issues
Install
Inside a PAM project (for example one created with pam init my-api --template http):
pam composer require pushinbr/pam-http-psr
It pulls in psr/http-message 2.x, psr/http-factory, psr/http-server-handler and psr/http-server-middleware.
Quick example
<?php declare(strict_types=1); use Pam\Http\Psr7\Factory; use Pam\Http\Psr15\Pipeline; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; $factory = new Factory(); $request = $factory->createServerRequest('GET', 'https://example.test/users/42'); $handler = new class($factory) implements RequestHandlerInterface { public function __construct(private readonly Factory $factory) { } public function handle(ServerRequestInterface $request): ResponseInterface { return $this->factory->createResponse(204)->withHeader('x-path', $request->getUri()->getPath()); } }; $response = (new Pipeline($handler))->handle($request);
Pipeline accepts a list of MiddlewareInterface instances or callables as its second argument and runs them in order before the handler.
What you can build
- Running PSR-15 middleware in a PAM application
- Adapting libraries that require PSR-7 values
- Migrating existing PSR-based HTTP code incrementally
| Role | HTTP interoperability adapter |
| Execution path | PHP-FIG PSR interfaces · PAM HTTP |
| This repository owns | Request, response, middleware, and factory implementations |
| Boundary | Not a server or router; conversion has a measurable boundary cost |
What is inside
| Namespace | Classes | Interfaces |
|---|---|---|
Pam\Http\Psr7 |
Stream, Uri, ServerRequest, Request, Response, UploadedFile |
PSR-7 |
Pam\Http\Psr7 |
Factory |
PSR-17 (request, response, server request, stream, uploaded file, URI) |
Pam\Http\Psr15 |
Pipeline |
PSR-15 RequestHandlerInterface |
The public namespaces Pam\Http\Psr7 and Pam\Http\Psr15 are preserved from the earlier package names (see the changelog).
Docs
Part of the PAM ecosystem
PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.
| PAM | PAM Desktop | PAM Native | Ecosystem |
|---|---|---|---|
| the runtime and CLI | native desktop apps in PHP | native Android and iOS apps in PHP | every official package and plugin |
Docs: push-in.github.io/pam-docs · Issues
Apache License 2.0: use, modify and distribute for any purpose, including commercially · Made in Brazil by Pushin