PHPackages                             fast-forward/http-message - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. fast-forward/http-message

ActiveLibrary[HTTP &amp; Networking](/categories/http)

fast-forward/http-message
=========================

Fast Forward PSR-7 HTTP Message utility classes

v1.4.0(3mo ago)04502MITPHPPHP ^8.3CI passing

Since Jun 30Pushed 2mo agoCompare

[ Source](https://github.com/php-fast-forward/http-message)[ Packagist](https://packagist.org/packages/fast-forward/http-message)[ Docs](https://github.com/php-fast-forward)[ RSS](/packages/fast-forward-http-message/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (8)Versions (6)Used By (2)

Fast Forward HTTP Message
=========================

[](#fast-forward-http-message)

[![PHP Version](https://camo.githubusercontent.com/c9b19f1cbf8aefb8c278c8b5d392b64401164a08fced6ccbf376b32135d6714f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/releases/)[![Composer Package](https://camo.githubusercontent.com/ffae0cbd496eee725ca1ae7b2cc2d17cab13bc5d85d4870ff24ecdb7f3b750bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d666173742d2d666f7277617264253246687474702d2d6d6573736167652d4632384431412e7376673f6c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/fast-forward/http-message)[![PSR-7](https://camo.githubusercontent.com/a00d7713ba8deadec13f96f0b7caeaf40f31f44d7d9d01f6b6475fd25b50ccc5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d372d687474702d2d6d6573736167652d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php-fig.org/psr/psr-7/)[![Tests](https://camo.githubusercontent.com/e35fcbdaabb1c1e28eabcf71ff6dc4a0284993d7531c47a0cdf08629fbf48a60/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7068702d666173742d666f72776172642f687474702d6d6573736167652f74657374732e796d6c3f6c6f676f3d676974687562616374696f6e73266c6f676f436f6c6f723d7768697465266c6162656c3d746573747326636f6c6f723d323243353545)](https://github.com/php-fast-forward/http-message/actions/workflows/tests.yml)[![Coverage](https://camo.githubusercontent.com/783041b70aa9cfca2a0969ddc49e11178a3367b14165ef787853fdc3075f43b3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d706870756e69742d3441444538303f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php-fast-forward.github.io/http-message/coverage/index.html)[![Docs](https://camo.githubusercontent.com/1bcf4b20f0cf94cfdeb1fa68bfd77876b66e79ed5a124d845552e89e6cd49981/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6465706c6f796d656e74732f7068702d666173742d666f72776172642f687474702d6d6573736167652f6769746875622d70616765733f6c6f676f3d72656164746865646f6373266c6f676f436f6c6f723d7768697465266c6162656c3d646f6373266c6162656c436f6c6f723d31453239334226636f6c6f723d333842444638267374796c653d666c6174)](https://php-fast-forward.github.io/http-message/index.html)[![License](https://camo.githubusercontent.com/e4946b53e6a4c35d937c10d24636e4f27434528b4acc3b057481bc0a35ccfc4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068702d666173742d666f72776172642f687474702d6d6573736167653f636f6c6f723d363437343842)](LICENSE)[![GitHub Sponsors](https://camo.githubusercontent.com/d61f432861a7c60e0a9620738dffd3b884bcf392c86e48a2cc87ea57a077e90a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f7068702d666173742d666f72776172643f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d776869746526636f6c6f723d454334383939)](https://github.com/sponsors/php-fast-forward)

A modern PHP library for working with PSR-7 HTTP Messages, focusing on immutability, strict typing, and developer ergonomics. Part of the [Fast Forward](https://github.com/php-fast-forward) ecosystem.

---

✨ Features
----------

[](#-features)

- ✅ 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

---

📦 Installation
--------------

[](#-installation)

```
composer require fast-forward/http-message
```

Requirements: PHP 8.3+, Composer

---

🛠️ Usage
--------

[](#️-usage)

### JSON Response Example

[](#json-response-example)

```
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}
```

### Payload Access and Immutability

[](#payload-access-and-immutability)

```
$newResponse = $response->withPayload(['success' => false]);

echo $response->getPayload()['success']; // true
echo $newResponse->getPayload()['success']; // false
```

### Text Response Example

[](#text-response-example)

```
use FastForward\Http\Message\TextResponse;
$text = new TextResponse('Hello, world!');
```

### Empty Response Example

[](#empty-response-example)

```
use FastForward\Http\Message\EmptyResponse;
$empty = new EmptyResponse();
```

### Redirect Response Example

[](#redirect-response-example)

```
use FastForward\Http\Message\RedirectResponse;
$redirect = new RedirectResponse('https://example.com', true); // Permanent redirect
```

---

🧰 API Summary
-------------

[](#-api-summary)

Class/MethodDescriptionDocs[JsonResponse](docs/api/responses.rst)JSON response with automatic headers[docs](docs/api/responses.rst)[TextResponse](docs/api/responses.rst)Plain text response[docs](docs/api/responses.rst)[HtmlResponse](docs/api/responses.rst)HTML response with correct Content-Type[docs](docs/api/responses.rst)[EmptyResponse](docs/api/responses.rst)HTTP 204 No Content response[docs](docs/api/responses.rst)[RedirectResponse](docs/api/responses.rst)HTTP redirect response (301/302)[docs](docs/api/responses.rst)[getPayload()](docs/api/payload.rst)Returns the payload of the response[docs](docs/api/payload.rst)[withPayload($data)](docs/api/payload.rst)Returns a new instance with a different payload[docs](docs/api/payload.rst)---

🔌 Integration
-------------

[](#-integration)

- Works out of the box with any PSR-7 compatible framework or library
- Designed to extend and complement [`nyholm/psr7`](https://github.com/Nyholm/psr7)
- Can be used with [fast-forward/container](https://github.com/php-fast-forward/container) for dependency injection

---

📁 Directory Structure Example
-----------------------------

[](#-directory-structure-example)

```
src/
├── EmptyResponse.php
├── HtmlResponse.php
├── JsonResponse.php
├── TextResponse.php
├── RedirectResponse.php
├── ...
```

---

⚙️ Advanced/Customization
-------------------------

[](#️-advancedcustomization)

- 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

---

🛠️ Versioning &amp; Breaking Changes
------------------------------------

[](#️-versioning--breaking-changes)

- v1.4: PHP 8.3+ required, stricter typing, improved docs
- v1.0: Initial release

---

❓ FAQ
-----

[](#-faq)

**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.

---

🛡 License
---------

[](#-license)

MIT © 2026 [Felipe Sayão Lobato Abreu](https://github.com/mentordosnerds)

---

🤝 Contributing
--------------

[](#-contributing)

Contributions, issues, and feature requests are welcome!
Feel free to open a [GitHub Issue](https://github.com/php-fast-forward/http-message/issues) or submit a Pull Request.

---

🔗 Links
-------

[](#-links)

- [Repository](https://github.com/php-fast-forward/http-message)
- [Packagist](https://packagist.org/packages/fast-forward/http-message)
- [Sphinx Documentation](docs/index.rst)
- [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119)
- [PSR-7](https://www.php-fig.org/psr/psr-7/)
- [PSR-15](https://www.php-fig.org/psr/psr-15/)
- [nyholm/psr7](https://github.com/Nyholm/psr7)

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Total

5

Last Release

96d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.4.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/bb658791d4db57e57ac164a268f94340ddff4d1ee0aad1358d4593847051a9fe?d=identicon)[coisa](/maintainers/coisa)

---

Top Contributors

[![coisa](https://avatars.githubusercontent.com/u/426835?v=4)](https://github.com/coisa "coisa (30 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

httphttp-messagephpphp-httpphp-librarypsr-7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fast-forward-http-message/health.svg)

```
[![Health](https://phpackages.com/badges/fast-forward-http-message/health.svg)](https://phpackages.com/packages/fast-forward-http-message)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[aimeos/aimeos-core

Full-featured e-commerce components for high performance online shops

4.5k361.1k75](/packages/aimeos-aimeos-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
