A modern PHP library for working with PSR-7 HTTP Messages, focusing on immutability, strict typing, and developer ergonomics. Part of the Fast Forward ecosystem.
- ✅ Fully PSR-7 compliant
- ✅ Strictly typed for PHP 8.3+
- ✅ Immutable by design (PSR-7 standard)
- ✅ Convenient JSON, HTML, Text, Empty, and Redirect responses
- ✅ Payload-aware interfaces for reusable patterns
- ✅ No external dependencies beyond PSR-7
composer require fast-forward/http-messageRequirements: PHP 8.3+, Composer
use FastForward\Http\Message\JsonResponse;
$response = new JsonResponse(['success' => true]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('Content-Type'); // application/json; charset=utf-8
echo (string) $response->getBody(); // {"success":true}$newResponse = $response->withPayload(['success' => false]);
echo $response->getPayload()['success']; // true
echo $newResponse->getPayload()['success']; // falseuse FastForward\Http\Message\TextResponse;
$text = new TextResponse('Hello, world!');use FastForward\Http\Message\EmptyResponse;
$empty = new EmptyResponse();use FastForward\Http\Message\RedirectResponse;
$redirect = new RedirectResponse('https://example.com', true); // Permanent redirect| Class/Method | Description | Docs |
|---|---|---|
| JsonResponse | JSON response with automatic headers | docs |
| TextResponse | Plain text response | docs |
| HtmlResponse | HTML response with correct Content-Type | docs |
| EmptyResponse | HTTP 204 No Content response | docs |
| RedirectResponse | HTTP redirect response (301/302) | docs |
| getPayload() | Returns the payload of the response | docs |
| withPayload($data) | Returns a new instance with a different payload | docs |
- Works out of the box with any PSR-7 compatible framework or library
- Designed to extend and complement
nyholm/psr7 - Can be used with fast-forward/container for dependency injection
src/
├── EmptyResponse.php
├── HtmlResponse.php
├── JsonResponse.php
├── TextResponse.php
├── RedirectResponse.php
├── ...
- Extend any response class to add custom logic
- Compose with other PSR-7 middlewares or response decorators
- All interfaces are public and designed for extension
- v1.4: PHP 8.3+ required, stricter typing, improved docs
- v1.0: Initial release
Q: What PHP version is required?
A: PHP 8.3 or higher.
Q: Is this library PSR-7 compliant?
A: Yes, all responses and streams are fully PSR-7 compliant and extend Nyholm's implementation.
Q: How do I create a JSON response?
A: Use JsonResponse and pass your payload to the constructor. The Content-Type header is set automatically.
Q: How do I work with payloads?
A: Use getPayload() to retrieve the payload and withPayload($payload) to create a new instance with a different payload.
Q: Can I use this with any framework?
A: Yes, as long as your framework supports PSR-7 messages.
Q: How do I handle authentication headers?
A: Use the Authorization header utility and credential classes for parsing and handling authentication schemes.
MIT © 2026 Felipe Sayão Lobato Abreu
Contributions, issues, and feature requests are welcome!
Feel free to open a GitHub Issue or submit a Pull Request.