|
| 1 | +# Fast Forward HTTP Message |
| 2 | + |
| 3 | +[](https://opensource.org/licenses/MIT) |
| 4 | +[](https://github.com/php-fast-forward/http-message/actions) |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +The **Fast Forward HTTP Message** library provides utility classes and implementations for working with PSR-7 HTTP Messages in PHP, with a strong focus on immutability, strict typing, and developer ergonomics. |
| 9 | + |
| 10 | +This library is designed to extend and complement [`nyholm/psr7`](https://github.com/Nyholm/psr7), providing additional structures for managing payloads, including convenient support for JSON and other payload-centric responses. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Features |
| 15 | + |
| 16 | +✅ Fully PSR-7 compliant |
| 17 | +✅ Strictly typed for PHP 8.2+ |
| 18 | +✅ Immutable by design (PSR-7 standard) |
| 19 | +✅ Convenient JSON response with automatic headers |
| 20 | +✅ Payload-aware interfaces for reusable patterns |
| 21 | +✅ No external dependencies beyond PSR-7 |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Installation |
| 26 | + |
| 27 | +This package requires **PHP 8.2 or higher** and can be installed via Composer: |
| 28 | + |
| 29 | +```bash |
| 30 | +composer require fast-forward/http-message |
| 31 | +``` |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +### Json Response Example |
| 36 | + |
| 37 | +```php |
| 38 | +use FastForward\Http\Message\JsonResponse; |
| 39 | + |
| 40 | +$response = new JsonResponse(['success' => true]); |
| 41 | + |
| 42 | +echo $response->getStatusCode(); // 200 |
| 43 | +echo $response->getHeaderLine('Content-Type'); // application/json; charset=utf-8 |
| 44 | + |
| 45 | +echo (string) $response->getBody(); // {"success":true} |
| 46 | +``` |
| 47 | + |
| 48 | +### Payload Access and Immutability |
| 49 | + |
| 50 | +```php |
| 51 | +$newResponse = $response->withPayload(['success' => false]); |
| 52 | + |
| 53 | +echo $response->getPayload()['success']; // true |
| 54 | +echo $newResponse->getPayload()['success']; // false |
| 55 | +``` |
| 56 | + |
| 57 | +## 🛡 License |
| 58 | + |
| 59 | +This package is open-source software licensed under the [MIT License](https://opensource.org/licenses/MIT). |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## 🤝 Contributing |
| 64 | + |
| 65 | +Contributions, issues, and feature requests are welcome! |
| 66 | +Feel free to open a [GitHub Issue](https://github.com/php-fast-forward/http-message/issues) or submit a Pull Request. |
0 commit comments