PHPackages                             phppkg/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. phppkg/http-message

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

phppkg/http-message
===================

http message library of the php, implement the PSR7

v2.0.0(4y ago)6513↓100%MITPHPPHP &gt;8.0.0CI failing

Since Sep 11Pushed 1y ago3 watchersCompare

[ Source](https://github.com/phppkg/http-message)[ Packagist](https://packagist.org/packages/phppkg/http-message)[ Docs](https://github.com/phppkg/http-message)[ RSS](/packages/phppkg-http-message/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (17)Used By (0)

http message
============

[](#http-message)

[![License](https://camo.githubusercontent.com/891f07bf06a7c6c761723a4f34d2223617dbd152bab190258fac80a95c6a094c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870706b672f687474702d6d6573736167652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Php Version](https://camo.githubusercontent.com/b8c0dd13660830081455657e3deb46e1fd731d422a6a37835ba161c9a781a7a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706870706b672f687474702d6d6573736167653f6d61784167653d32353932303030)](https://packagist.org/packages/phppkg/http-message)[![Latest Stable Version](https://camo.githubusercontent.com/06c91a1e77feb486833f7e7384e3bfb47386aa4e6e44d5ec8ba842c110ffbc87/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870706b672f687474702d6d6573736167652e737667)](https://packagist.org/packages/phppkg/http-message)

http message 库，实现自 PSR 7。

安装
--

[](#安装)

- 通过 `composer.json`

编辑 `composer.json`，在 `require` 添加

```
"phppkg/http-message": "dev-master",

```

保存，然后执行: `composer update`

- 通过 `composer require`

```
composer require phppkg/http-message
```

- git拉取

```
git clone https://github.com/phppkg/http-message.git // github
```

使用
--

[](#使用)

### 基本使用

[](#基本使用)

```
use PhpPkg\Http\Message\Request;
use PhpPkg\Http\Message\Response;

$request = new Request($method, $uri);
$request = new ServerRequest(... ...);
$response = new Response($code);
... ...
```

### 工厂方法

[](#工厂方法)

使用提供的工厂方法可以快速创建想要的实例对象。

```
use PhpPkg\Http\Message\HttpFactory;

$request = HttpFactory::createRequest($method, $uri);

// server request
$request = HttpFactory::createServerRequest('GET', 'http://www.abc.com/home');
$request = HttpFactory::createServerRequestFromArray($_SERVER);

$response = HttpFactory::createResponse($code);
```

### 扩展

[](#扩展)

```
use PhpPkg\Http\Message\Request;
use PhpPkg\Http\Message\Traits\ExtendedRequestTrait;

class MyRequest extends Request {
   use ExtendedRequestTrait; // 里面提供的更多方便使用的方法
}

//

$request = new MyRequest(...);

$age = $request->getInt('age');
$name = $request->getTrimmed('name');
```

```
use PhpPkg\Http\Message\Response;
use PhpPkg\Http\Message\Traits\ExtendedResponseTrait;

class MyResponse extends Response {
   use ExtendedResponseTrait;
}
```

项目地址
----

[](#项目地址)

- **github**

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 98.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 ~103 days

Recently: every ~259 days

Total

16

Last Release

1612d ago

Major Versions

v1.5.1 → v2.0.02021-12-08

PHP version history (4 changes)v1.0.0PHP &gt;=7.0.0

v1.2.1PHP &gt;7.0.0

v1.4.0PHP &gt;7.1.0

v2.0.0PHP &gt;8.0.0

### Community

Maintainers

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

---

Top Contributors

[![inhere](https://avatars.githubusercontent.com/u/5302062?v=4)](https://github.com/inhere "inhere (60 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

http-messagespsr-7requestresponsehttppsr7librarytool

### Embed Badge

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

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

###  Alternatives

[league/openapi-psr7-validator

Validate PSR-7 messages against OpenAPI (3.0.2) specifications expressed in YAML or JSON

55615.9M69](/packages/league-openapi-psr7-validator)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[swlib/http

Swlib-HTTP base class repository, PSR implementation

11145.4k4](/packages/swlib-http)

PHPackages © 2026

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