PHPackages                             wangschang/requestlimit - 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. wangschang/requestlimit

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

wangschang/requestlimit
=======================

requestlimit

21PHP

Since Jun 25Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

requestlimit 请求限流器
==================

[](#requestlimit-请求限流器)

1.支持方法
------

[](#1支持方法)

支持通过redis 和文件的存储，自己扩展可以通过实现接口 `RequestLimit\StorageInterface` 来增加新的支持类型。 支持窗口和令牌桶的策略，可以通过实现接口 `RequestLimit\StrategyInterface` 来扩展其他策略。

[![流程图](assets/chart.png)](assets/chart.png)

2. 使用方法
-------

[](#2-使用方法)

详情参考 [example 例子](https://github.com/wangschang/requestlimit/blob/master/example.php)

```
require   'vendor/autoload.php';

use Predis\Client;
use RequestLimit\RequestLimit;
use RequestLimit\FileStorage;
use RequestLimit\RedisStorage;
use RequestLimit\RequestLimitException;
use RequestLimit\WindowsStrategy;
use RequestLimit\BucketStrategy;

$redis = new Client(['scheme' => 'tcp','host'   => '127.0.0.1','port'   => 6379]);
try{
       //$storgae = new FileStorage('/data/wwwlogs/requestlimit');//file storage
       $storgae = new RedisStorage($redis);//redis storage
        //$requestlimit = new RequestLimit(new WindowsStrategy(10,20),$storgae);
        $requestlimit = new RequestLimit(new BucketStrategy(1,0.1,5),$storgae);
        $uid = 1;
        if($requestlimit->isAllow($uid)){
                echo "allow";
        }else{
                echo "not allow";
 }catch(RequestLimitException $e){
       print_r($e->getRequestLimitMessage());
}catch(\Exception $e){
       echo $e->getMessage();
}
```

```

```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

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/a9620436b6f6d4c16d95b5407ce2b50c09c2f93ec99546d819248ebf7e41329a?d=identicon)[wangschang](/maintainers/wangschang)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/wangschang-requestlimit/health.svg)

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

PHPackages © 2026

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