PHPackages                             janfish/frequency-limiter - 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. janfish/frequency-limiter

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

janfish/frequency-limiter
=========================

Frequency limiter base on token bucket algorithm

235PHP

Since Apr 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/zeng444/frequency-limiter)[ Packagist](https://packagist.org/packages/janfish/frequency-limiter)[ RSS](/packages/janfish-frequency-limiter/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Frequency limiter
=================

[](#frequency-limiter)

> Frequency limiter base on token bucket algorithm

Main features
-------------

[](#main-features)

- Implement this feature by lua script
- Shared locks are implemented when concurrent requests occur

How to use
----------

[](#how-to-use)

```
$redisConfig = [
    'scheme' => 'tcp',
    'host' => 'redis',
    'port' => 6379,
    'database' => 5,
];
$frequencyLimiter = new FrequencyLimiter($redisConfig);
$result = $frequencyLimiter->setRules([
    ['interval' => 10, 'limit' => 5, 'name' => 'clock0:userId:752'],
    ['interval' => 35, 'limit' => 15, 'name' => 'clock1:userId:752'],
    ['interval' => 80, 'limit' => 30, 'name' => 'clock2:userId:752'],
]);
if (!$frequencyLimiter->check()) {
    die($frequencyLimiter->getCurrentRuleIndex());
}
```

```
$frequencyLimiter = new FrequencyLimiter($redisConfig);
$result = $frequencyLimiter->setRules([
    ['interval' => 10, 'limit' => 5, 'name' => $userName.':userId:752'],
]);
if (!$frequencyLimiter->check()) {
    die('Maximum number of errors reached');
}
if($userName === 'accountName' && $password==='abc'){
    $frequencyLimiter->reset();
}
echo "Login successful"
```

Rules configuration
-------------------

[](#rules-configuration)

keytypedescintervalintInterval time in secondslimitintToken quantitynamestringName of bucketReference
---------

[](#reference)

- [https://en.wikipedia.org/wiki/Token\_bucket](https://en.wikipedia.org/wiki/Token_bucket)
-

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/60a62fd9f299f25558ac4a898ae3833bd7185ba4706bb167a8cabf05a3d96955?d=identicon)[Robert Zeng](/maintainers/Robert%20Zeng)

---

Top Contributors

[![zeng444](https://avatars.githubusercontent.com/u/941266?v=4)](https://github.com/zeng444 "zeng444 (10 commits)")

### Embed Badge

![Health badge](/badges/janfish-frequency-limiter/health.svg)

```
[![Health](https://phpackages.com/badges/janfish-frequency-limiter/health.svg)](https://phpackages.com/packages/janfish-frequency-limiter)
```

PHPackages © 2026

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