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(1mo ago)01272MITPHPPHP ^8.3CI passing

Since Jun 30Pushed 1mo 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 1mo ago

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

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

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

[![PHP Version](https://camo.githubusercontent.com/e69fc10ad0d3845d44d08b0eeedd6dd7a5bfa4ab872e68e26b131554122d35d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c75652e737667)](https://www.php.net/releases/)[![License](https://camo.githubusercontent.com/c587e2cf88aec156efbf8d9f8d5cae88510b3ecf26950b0e98109c37b9ee4640/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068702d666173742d666f72776172642f687474702d6d6573736167652e737667)](https://opensource.org/licenses/MIT)[![Tests](https://github.com/php-fast-forward/http-message/actions/workflows/tests.yml/badge.svg)](https://github.com/php-fast-forward/http-message/actions)[![Coverage](https://camo.githubusercontent.com/0d75041a8cfd683d7237a3344382096a22e4bd1195dc89938869aee400843bd6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d68746d6c2d677265656e3f6c6f676f3d706870756e6974266c6162656c3d636f766572616765267374796c653d666c6174)](https://php-fast-forward.github.io/http-message/coverage/)[![Downloads](https://camo.githubusercontent.com/9c8ea79c2280d969da26a77bb4d16819c54438326744364b130e68d99062c365/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666173742d666f72776172642f687474702d6d657373616765)](https://packagist.org/packages/fast-forward/http-message)

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

45

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.4% 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

50d 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 (27 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

[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

536204.9M23](/packages/league-uri-interfaces)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[openswoole/core

Openswoole core library

181.1M32](/packages/openswoole-core)[mimmi20/browser-detector

Library to detect Browsers and Devices

48153.5k3](/packages/mimmi20-browser-detector)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)

PHPackages © 2026

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