PHPackages                             httpsoft/http-response - 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. httpsoft/http-response

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

httpsoft/http-response
======================

PSR-7 Response implementations

1.1.0(3y ago)360.6k↑119.6%18MITPHPPHP ^7.4|^8.0CI failing

Since Aug 23Pushed 1y ago2 watchersCompare

[ Source](https://github.com/httpsoft/http-response)[ Packagist](https://packagist.org/packages/httpsoft/http-response)[ Docs](https://httpsoft.org/)[ RSS](/packages/httpsoft-http-response/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (8)

HTTP Response
=============

[](#http-response)

[![License](https://camo.githubusercontent.com/2dd4def60578767b0a4c92e33912e4c482895095d533c3442210e55f4a09a48c/68747470733a2f2f706f7365722e707567782e6f72672f68747470736f66742f687474702d726573706f6e73652f6c6963656e7365)](https://packagist.org/packages/httpsoft/http-response)[![Latest Stable Version](https://camo.githubusercontent.com/7ac23d61540f7078412cbce4e5084f1cc223423eaf5b93c6de19c04135b14302/68747470733a2f2f706f7365722e707567782e6f72672f68747470736f66742f687474702d726573706f6e73652f76)](https://packagist.org/packages/httpsoft/http-response)[![Total Downloads](https://camo.githubusercontent.com/96e4a669fd67ed7ff76c6f2661353938d4823e732551ac3d7701afea8af732c9/68747470733a2f2f706f7365722e707567782e6f72672f68747470736f66742f687474702d726573706f6e73652f646f776e6c6f616473)](https://packagist.org/packages/httpsoft/http-response)[![GitHub Build Status](https://github.com/httpsoft/http-response/workflows/build/badge.svg)](https://github.com/httpsoft/http-response/actions)[![GitHub Static Analysis Status](https://github.com/httpsoft/http-response/workflows/static/badge.svg)](https://github.com/httpsoft/http-response/actions)[![Scrutinizer Code Coverage](https://camo.githubusercontent.com/986019c7cbf566a73094b9a2500dbd9f77a3bd4837ca794350cb2c6449874a1f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f68747470736f66742f687474702d726573706f6e73652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/httpsoft/http-response/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/20f7f0399f899a010da0634d0633eacff32a159ab38cc88213f967104d3dddfc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f68747470736f66742f687474702d726573706f6e73652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/httpsoft/http-response/?branch=master)

This package contains a collection of classes that implements [Psr\\Http\\Message\\ResponseInterface](https://github.com/php-fig/http-message/blob/master/src/ResponseInterface.php) from [PSR-7 HTTP Message](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md) in accordance with the [RFC 7230](https://tools.ietf.org/html/rfc7230) and [RFC 7231](https://tools.ietf.org/html/rfc7231) specifications.

Depends on the [httpsoft/http-message](https://github.com/httpsoft/http-message) package.

Documentation
-------------

[](#documentation)

- [In English language](https://httpsoft.org/docs/response).
- [In Russian language](https://httpsoft.org/ru/docs/response).

Installation
------------

[](#installation)

This package requires PHP version 7.4 or later.

```
composer require httpsoft/http-response

```

Usage standard response
-----------------------

[](#usage-standard-response)

```
use HttpSoft\Message\Response;

$response = new Response();
// default values
$response->getStatusCode(); // 200
$response->getReasonPhrase(); // 'OK'
$response->getBody()->getContents(); // ''
$response->getBody()->getMetadata('uri') // 'php://temp'
$response->getHeaders(); // []
$response->getProtocolVersion(); // '1.1'

// Create with the passed parameters
$response = new Response(404, ['Content-Language' => 'en'], 'php://memory', '2');
$response->getStatusCode(); // 404
$response->getReasonPhrase(); // 'Not Found'
$response->getBody()->getContents(); // ''
$response->getBody()->getMetadata('uri') // 'php://memory'
$response->getHeaders(); // ['Content-Language' => ['en']]
$response->getProtocolVersion(); // '2'

// Write to the response body:
$response->getBody()->write('Content');
$response->getBody()->getContents(); // 'Content'

// With `Content-Type` header:
$newResponse = $response->withHeader('Content-Type', 'text/plain');
$newResponse->getHeaderLine('content-type'); // 'text/plain'
$newResponse->getHeaders(); // ['Content-Language' => ['ru'], 'Content-Type' => ['text/plain']]

// With status code:
$newResponse = $response->withStatus(500);
$newResponse->getStatusCode(); // 500
$newResponse->getReasonPhrase(); // 'Internal Server Error'

// With status code and reason phrase:
$newResponse = $response->withStatus(599, 'Custom Phrase');
$newResponse->getStatusCode(); // 599
$newResponse->getReasonPhrase(); // 'Custom Phrase'
```

Usage custom responses
----------------------

[](#usage-custom-responses)

```
// Create `Psr\Http\Message\ResponseInterface` instance from HTML:
$response = new HttpSoft\Response\HtmlResponse('HTML');
$response->getHeaderLine('content-type'); // 'text/html; charset=UTF-8'

// Create `Psr\Http\Message\ResponseInterface` instance from data to convert to JSON:
$response = new HttpSoft\Response\JsonResponse(['key' => 'value']);
$response->getHeaderLine('content-type'); // 'application/json; charset=UTF-8'

// Create `Psr\Http\Message\ResponseInterface` instance from Text:
$response = new HttpSoft\Response\TextResponse('Text');
$response->getHeaderLine('content-type'); // 'text/plain; charset=UTF-8'

// Create `Psr\Http\Message\ResponseInterface` instance from XML:
$response = new HttpSoft\Response\XmlResponse('XML');
$response->getHeaderLine('content-type'); // 'application/xml; charset=UTF-8'

// Create `Psr\Http\Message\ResponseInterface` instance for redirect:
$response = new HttpSoft\Response\RedirectResponse('https/example.com');
$response->getHeaderLine('location'); // 'https/example.com'

// Create `Psr\Http\Message\ResponseInterface` instance for empty response:
$response = new HttpSoft\Response\EmptyResponse();
$response->getStatusCode(); // 204
$response->getReasonPhrase(); // 'No Content'
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~197 days

Recently: every ~246 days

Total

6

Last Release

1155d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ab952aaa5ac8f82d6e96ef74c2f69082674a97eb3bc62f9d96c7304b2b4b082?d=identicon)[devanych](/maintainers/devanych)

---

Top Contributors

[![devanych](https://avatars.githubusercontent.com/u/20116244?v=4)](https://github.com/devanych "devanych (52 commits)")

---

Tags

httphttp-messagehttp-responsephppsr-7responseshttppsr-7http-messagephpresponseshttp-response

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/httpsoft-http-response/health.svg)

```
[![Health](https://phpackages.com/badges/httpsoft-http-response/health.svg)](https://phpackages.com/packages/httpsoft-http-response)
```

###  Alternatives

[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39397.5M314](/packages/fig-http-message-util)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[httpsoft/http-server-request

Infrastructure for creating PSR-7 ServerRequest and UploadedFile

15127.7k33](/packages/httpsoft-http-server-request)[httpsoft/http-basis

Simple and fast HTTP microframework implementing PSR standards

1343.1k1](/packages/httpsoft-http-basis)[popphp/pop-http

Pop Http Component for Pop PHP Framework

1020.4k14](/packages/popphp-pop-http)

PHPackages © 2026

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