PHPackages                             nyholm/psr7 - 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. nyholm/psr7

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

nyholm/psr7
===========

A fast PHP7 implementation of PSR-7

1.8.2(1y ago)1.3k235.4M↓13.3%80[4 issues](https://github.com/Nyholm/psr7/issues)[1 PRs](https://github.com/Nyholm/psr7/pulls)20MITPHPPHP &gt;=7.2CI failing

Since Mar 11Pushed 5mo ago25 watchersCompare

[ Source](https://github.com/Nyholm/psr7)[ Packagist](https://packagist.org/packages/nyholm/psr7)[ Docs](https://tnyholm.se)[ GitHub Sponsors](https://github.com/Zegnat)[ GitHub Sponsors](https://github.com/nyholm)[ RSS](/packages/nyholm-psr7/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (26)Used By (20)Security (1)

PSR-7 implementation
====================

[](#psr-7-implementation)

[![Latest Version](https://camo.githubusercontent.com/e76e6d62c4a82c1ac1720571b845aac1cc2bf8b9147f4b3c5e23f04ff9569e52/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4e79686f6c6d2f707372372e7376673f7374796c653d666c61742d737175617265)](https://github.com/Nyholm/psr7/releases)[![Total Downloads](https://camo.githubusercontent.com/df0c2cbb5796073860a77f4ccbb8c370cbafa0fe3326e58e4449a6281682359a/68747470733a2f2f706f7365722e707567782e6f72672f6e79686f6c6d2f707372372f646f776e6c6f616473)](https://packagist.org/packages/nyholm/psr7)[![Monthly Downloads](https://camo.githubusercontent.com/f234c2afb28e19092371204fe40e9b6d0ddbdee595fc94416ade60ef4052a3db/68747470733a2f2f706f7365722e707567782e6f72672f6e79686f6c6d2f707372372f642f6d6f6e74686c792e706e67)](https://packagist.org/packages/nyholm/psr7)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Static analysis](https://github.com/Nyholm/psr7/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/Nyholm/psr7/actions/workflows/static.yml?query=branch%3Amaster)[![Tests](https://github.com/Nyholm/psr7/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/Nyholm/psr7/actions/workflows/tests.yml?query=branch%3Amaster)

A super lightweight PSR-7 implementation. Very strict and very fast.

DescriptionGuzzleLaminasSlimNyholmLines of code3.3003.1001.9001.000PSR-7\*66%100%75%100%PSR-17NoYesYesYesHTTPlugNoNoNoYesPerformance (runs per second)\*\*14.55314.70313.41617.734\* Percent of completed tests in

\*\* Benchmark with 50.000 runs. See  (higher is better)

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

[](#installation)

```
composer require nyholm/psr7
```

If you are using Symfony Flex then you get all message factories registered as services.

Usage
-----

[](#usage)

The PSR-7 objects do not contain any other public methods than those defined in the [PSR-7 specification](https://www.php-fig.org/psr/psr-7/).

### Create objects

[](#create-objects)

Use the PSR-17 factory to create requests, streams, URIs etc.

```
$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory();
$request = $psr17Factory->createRequest('GET', 'http://tnyholm.se');
$stream = $psr17Factory->createStream('foobar');
```

### Sending a request

[](#sending-a-request)

With [HTTPlug](http://httplug.io/) or any other PSR-18 (HTTP client) you may send requests like:

```
composer require kriswallsmith/buzz
```

```
$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory();
$psr18Client = new \Buzz\Client\Curl($psr17Factory);

$request = $psr17Factory->createRequest('GET', 'http://tnyholm.se');
$response = $psr18Client->sendRequest($request);
```

### Create server requests

[](#create-server-requests)

The [`nyholm/psr7-server`](https://github.com/Nyholm/psr7-server) package can be used to create server requests from PHP superglobals.

```
composer require nyholm/psr7-server
```

```
$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory();

$creator = new \Nyholm\Psr7Server\ServerRequestCreator(
    $psr17Factory, // ServerRequestFactory
    $psr17Factory, // UriFactory
    $psr17Factory, // UploadedFileFactory
    $psr17Factory  // StreamFactory
);

$serverRequest = $creator->fromGlobals();
```

### Emitting a response

[](#emitting-a-response)

```
composer require laminas/laminas-httphandlerrunner
```

```
$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory();

$responseBody = $psr17Factory->createStream('Hello world');
$response = $psr17Factory->createResponse(200)->withBody($responseBody);
(new \Laminas\HttpHandlerRunner\Emitter\SapiEmitter())->emit($response);
```

Our goal
--------

[](#our-goal)

This package is currently maintained by [Tobias Nyholm](http://nyholm.se) and [Martijn van der Ven](https://vanderven.se/martijn/). They have decided that the goal of this library should be to provide a super strict implementation of [PSR-7](https://www.php-fig.org/psr/psr-7/) that is blazing fast.

The package will never include any extra features nor helper methods. All our classes and functions exist because they are required to fulfill the PSR-7 specification.

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance55

Moderate activity, may be stable

Popularity79

Solid adoption and visibility

Community59

Growing community involvement

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 61.6% 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 ~119 days

Recently: every ~127 days

Total

24

Last Release

617d ago

Major Versions

0.3.0 → 1.0.02018-08-02

PHP version history (4 changes)0.1.0PHP ^7.0

0.3.0PHP ^7.1

1.3.1PHP &gt;=7.1

1.7.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/401ccc5eea13c60cf807ae982af00e368e2166e2f26d8eb541dcd881a57385bc?d=identicon)[Nyholm](/maintainers/Nyholm)

---

Top Contributors

[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (122 commits)")[![Zegnat](https://avatars.githubusercontent.com/u/490579?v=4)](https://github.com/Zegnat "Zegnat (25 commits)")[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (20 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (2 commits)")[![sunkan](https://avatars.githubusercontent.com/u/568492?v=4)](https://github.com/sunkan "sunkan (2 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (2 commits)")[![rancoud](https://avatars.githubusercontent.com/u/1884186?v=4)](https://github.com/rancoud "rancoud (2 commits)")[![dbu](https://avatars.githubusercontent.com/u/76576?v=4)](https://github.com/dbu "dbu (1 commits)")[![Groruk](https://avatars.githubusercontent.com/u/5796460?v=4)](https://github.com/Groruk "Groruk (1 commits)")[![higoka](https://avatars.githubusercontent.com/u/16455725?v=4)](https://github.com/higoka "higoka (1 commits)")[![iambrosi](https://avatars.githubusercontent.com/u/297102?v=4)](https://github.com/iambrosi "iambrosi (1 commits)")[![kamalkhan](https://avatars.githubusercontent.com/u/4675979?v=4)](https://github.com/kamalkhan "kamalkhan (1 commits)")[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (1 commits)")[![murat11](https://avatars.githubusercontent.com/u/10486500?v=4)](https://github.com/murat11 "murat11 (1 commits)")[![alexislefebvre](https://avatars.githubusercontent.com/u/2071331?v=4)](https://github.com/alexislefebvre "alexislefebvre (1 commits)")[![ostrolucky](https://avatars.githubusercontent.com/u/496233?v=4)](https://github.com/ostrolucky "ostrolucky (1 commits)")[![ppetermann](https://avatars.githubusercontent.com/u/69334?v=4)](https://github.com/ppetermann "ppetermann (1 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (1 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (1 commits)")[![SharkMachine](https://avatars.githubusercontent.com/u/7488694?v=4)](https://github.com/SharkMachine "SharkMachine (1 commits)")

---

Tags

psr-17psr-7psr-7psr-17

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nyholm-psr7/health.svg)

```
[![Health](https://phpackages.com/badges/nyholm-psr7/health.svg)](https://phpackages.com/packages/nyholm-psr7)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.0B3.2k](/packages/guzzlehttp-psr7)[laminas/laminas-diactoros

PSR HTTP Message implementations

548105.8M965](/packages/laminas-laminas-diactoros)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[nyholm/psr7-server

Helper classes to handle PSR-7 server requests

9521.1M307](/packages/nyholm-psr7-server)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

586.6M81](/packages/laminas-laminas-stratigility)[elastic/transport

HTTP transport PHP library for Elastic products

2020.6M7](/packages/elastic-transport)

PHPackages © 2026

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