PHPackages                             arash/rlr - 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. arash/rlr

ActivePhp-library[Utility &amp; Helpers](/categories/utility)

arash/rlr
=========

rate limit request

v0.1.0(1y ago)09PHPPHP &gt;=5.4

Since Aug 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/arash-hosseinabady/rlr)[ Packagist](https://packagist.org/packages/arash/rlr)[ RSS](/packages/arash-rlr/feed)WikiDiscussions main Synced today

READMEChangelog (2)DependenciesVersions (4)Used By (0)

Rate limit request
------------------

[](#rate-limit-request)

### Requirement

[](#requirement)

- minimum php 5.4
- redis
- memcached
- For connect to Redis define and set `REDIS_HOST` and `REDIS_PORT` environment variable. Default value for host is `127.0.0.1` and port is `6379`.
- For connect to Memcached define and set `MEMCACHED_HOST` and `MEMCACHED_PORT` environment variable. Default value for host is `127.0.0.1` and port is `11211`.

### Installation

[](#installation)

- with composer: `composer require arash/rlr`
- manually:
    - yii:
        - copy this package to the desired directory
        - set blow config in `aliases` section `'@arash/rlr' => __DIR__ . 'pathToDirectory/rlr/src',`
    - laravel:
        - copy this package to `app/Services`
        - add `"arash\\rlr\\": "app/Services/rlr/src"` in `psr-4` of `autoload` section
        - run `composer dumpautoload`

### Usage

[](#usage)

use `RLRService` before the request arrive to action.

```
use arash\rlr\RLRService;

//default handler is memcache
$limiter = new RLRService(RLRService::HANDLER_REDIS);

//default is 10 request per 60 seconds.
//count of request per window
$limiter->handler->limit = 5;
//time window
$limiter->handler->window = 60;

//list of IPs that you want banned
$limiter->handler->banList = [];

if ($limiter->handler->isRateLimited()) {
    echo 'Rate limit exceeded. Please try again later.';
} else {
    echo 'Request successful.';
}
```

#### Yii

[](#yii)

Copy `RLRFilter.php` in `app\components` directory and add blow code in `behavior` of your component.

```
$behaviors['rlr'] = [
    'class' => 'app\components\RLRFilter',
    'only' => ['array of actions'],
    'except' => ['array of actions'],
    'handlerClass' => RLRService::HANDLER_REDIS, //default handler is memcache
    'limit' => 3, //count of request per window
    'window' => 15, //time window
    'message' => 'your message',
    'banList' => 'list of IPs in array or string that separate with comma'
];
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

674d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1888521?v=4)[arash-hosseinabady](/maintainers/arash-hosseinabady)[@arash-hosseinabady](https://github.com/arash-hosseinabady)

---

Top Contributors

[![arash-hosseinabady](https://avatars.githubusercontent.com/u/1888521?v=4)](https://github.com/arash-hosseinabady "arash-hosseinabady (5 commits)")

### Embed Badge

![Health badge](/badges/arash-rlr/health.svg)

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

###  Alternatives

[functional-php/pattern-matching

Pattern matching for PHP with automatic destructuring.

8280.1k](/packages/functional-php-pattern-matching)[beyondit/opencart-extension-installer

Custom Composer Installer for installing OpenCart Extensions

1020.6k6](/packages/beyondit-opencart-extension-installer)

PHPackages © 2026

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