PHPackages                             gzh/hyperf-cookie - 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. [Caching](/categories/caching)
4. /
5. gzh/hyperf-cookie

ActiveLibrary[Caching](/categories/caching)

gzh/hyperf-cookie
=================

The Hyperf Queued Cookie package.

v1.0.2(1y ago)020MITPHPPHP &gt;=7.3

Since Sep 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/guanzhihua168/hyperf-cookie)[ Packagist](https://packagist.org/packages/gzh/hyperf-cookie)[ RSS](/packages/gzh-hyperf-cookie/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Hyperf Cookie 组件
================

[](#hyperf-cookie-组件)

该组件移植自 Laravel（[illuminate/cookie](https://github.com/illuminate/cookie)），功能与 Laravel 保持一致。

> 注意，该组件与 Hyperf 官方组件差异很大，使用时切勿混淆。

安装
--

[](#安装)

```
composer require hyperf-ext/cookie
```

发布配置
----

[](#发布配置)

```
php bin/hyperf.php vendor:publish hyperf-ext/cookie
```

> 配置文件位于 `config/autoload/cookie.php`。

设置
--

[](#设置)

在配置文件 `config/autoload/middlewares.php` 中添加全局中间件 `HyperfExt\Cookie\Middleware\QueuedCookieMiddleware`。

如需对 Cookie 加密，额外添加全局中间件 `HyperfExt\Cookie\Middleware\EncryptCookieMiddleware`。

> 注意，使用 Cookie 加密中间件需要依赖 [`hyperf-ext/encryption`](https://github.com/hyperf-ext/encryption) 组件。 并且需求将该中间件放置在其他需要处理 Cookie 的中间件之前，以保证将请求中的加密 Cookie 解密。

使用
--

[](#使用)

在任何需要设置 Cookie 的地方注入 `HyperfExt\Cookie\Contract\CookieJarInterface`，该接口绑定的是 `HyperfExt\Cookie\CookieJar` 的代理类实例对象。

该对象存储在当前请求的协程上下文中，在当前协程周期内访问到的都是同一个对象。

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

611d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e936e11412523a7b3cd5d2515cd7541a5a518aa1987340353892308bcee9f33?d=identicon)[hz](/maintainers/hz)

---

Top Contributors

[![guanzhihua168](https://avatars.githubusercontent.com/u/21253675?v=4)](https://github.com/guanzhihua168 "guanzhihua168 (2 commits)")[![hzmain5](https://avatars.githubusercontent.com/u/173677285?v=4)](https://github.com/hzmain5 "hzmain5 (1 commits)")

---

Tags

phpcookiehyperf

### Embed Badge

![Health badge](/badges/gzh-hyperf-cookie/health.svg)

```
[![Health](https://phpackages.com/badges/gzh-hyperf-cookie/health.svg)](https://phpackages.com/packages/gzh-hyperf-cookie)
```

###  Alternatives

[lysice/hyperf-redis-lock

20101.3k7](/packages/lysice-hyperf-redis-lock)

PHPackages © 2026

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