PHPackages                             nasustop/hapi-rate-limit - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nasustop/hapi-rate-limit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nasustop/hapi-rate-limit
========================

3.0.0(3y ago)010MITPHPPHP &gt;=8.0

Since Apr 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/nasustop/hapi-rate-limit)[ Packagist](https://packagist.org/packages/nasustop/hapi-rate-limit)[ RSS](/packages/nasustop-hapi-rate-limit/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (9)Versions (5)Used By (0)

HapiRateLimit
=============

[](#hapiratelimit)

hyperf的限流组件

安装
--

[](#安装)

```
composer require nasustop/hapi-rate-limit

```

使用方法
----

[](#使用方法)

```
// 进程级限流，每个进程独立的限流服务，受进程重启影响
use Nasustop\HapiRateLimit\Rate\ProcessTokenBucket;
// 服务级限流，多进程共享限流服务，受服务重启影响【推荐使用】
use Nasustop\HapiRateLimit\Rate\MemoryTokenBucket;
// 应用级限流，多服务共享限流服务，不受服务重启影响，但受限于redis服务的性能【推荐使用】
use Nasustop\HapiRateLimit\Rate\RedisTokenBucket;

$processRate = new ProcessTokenBucket(1000, 1000, 1);
if (! $processRate->getToken(1)) {
    $response = ApplicationContext::getContainer()->get(ResponseInterface::class);
    return $response->json([
        'code' => 429,
        'msg' => 'To Many Requests.',
    ]);
}
$memoryRate = new MemoryTokenBucket(1000, 1000, 1);
if (! $memoryRate->getToken(1)) {
    $response = ApplicationContext::getContainer()->get(ResponseInterface::class);
    return $response->json([
        'code' => 429,
        'msg' => 'To Many Requests.',
    ]);
}
$redisRate = new RedisTokenBucket(
    redis: ApplicationContext::getContainer()->get(RedisFactory::class)->get('default'),
    key: 'hapi_rate_limit',
    capacity: 1000,
    rate: 1000,
    interval: 1
);
if (! $redisRate->getToken(1)) {
    $response = ApplicationContext::getContainer()->get(ResponseInterface::class);
    return $response->json([
        'code' => 429,
        'msg' => 'To Many Requests.',
    ]);
}

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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 ~19 days

Total

4

Last Release

1102d ago

Major Versions

1.0.2 → 3.0.02023-06-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/04611b4e26e4080a8441f8274c59331b0e3e858a0d836ed7c4a29dcf4a49ee93?d=identicon)[antsgo](/maintainers/antsgo)

---

Top Contributors

[![eaglexpf](https://avatars.githubusercontent.com/u/16461274?v=4)](https://github.com/eaglexpf "eaglexpf (7 commits)")

---

Tags

phphyperf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nasustop-hapi-rate-limit/health.svg)

```
[![Health](https://phpackages.com/badges/nasustop-hapi-rate-limit/health.svg)](https://phpackages.com/packages/nasustop-hapi-rate-limit)
```

###  Alternatives

[hyperf/nano

Scale Hyperf application down to a single file

43413.9k2](/packages/hyperf-nano)[hyperf/crontab

A crontab component for Hyperf.

131.7M76](/packages/hyperf-crontab)[hyperf/watcher

Hot reload watcher for Hyperf

17904.9k31](/packages/hyperf-watcher)

PHPackages © 2026

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