PHPackages                             jdimitrov/php-ratelimit - 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. jdimitrov/php-ratelimit

ActiveLibrary

jdimitrov/php-ratelimit
=======================

PHP rate limiting library with Leaky Bucket Algorithm

0.3(4y ago)171MITPHPPHP ^7.1

Since Dec 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/uliandim/php-ratelimit)[ Packagist](https://packagist.org/packages/jdimitrov/php-ratelimit)[ RSS](/packages/jdimitrov-php-ratelimit/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

PHP RateLimit
=============

[](#php-ratelimit)

PHP Rate Limiting Library With Leaky Bucket Algorithm with minimal external dependencies.

Installation
============

[](#installation)

`composer require jdimitrov/php-ratelimit`

Storage Adapters
================

[](#storage-adapters)

The PHP Rate Limit needs to know where to store data.

Depending on which adapter you install, you may need to install additional libraries (predis/predis) or PHP extensions (e.g. Redis, Memcached, APC)

- [APCu](https://pecl.php.net/package/APCu)
- [Redis](https://pecl.php.net/package/redis) or [Predis](https://github.com/nrk/predis)
- [Memcached](http://php.net/manual/en/intro.memcached.php)

Example
=======

[](#example)

Add uses:

```
use JDimitrov\RateLimit\RateLimit;
use JDimitrov\RateLimit\Adapter\APC as APCAdapter;
use JDimitrov\RateLimit\Adapter\Redis as RedisAdapter;
use JDimitrov\RateLimit\Adapter\Predis as PredisAdapter;
use JDimitrov\RateLimit\Adapter\Memcached as MemcachedAdapter;

```

```
$adapter = new RedisAdapter((new \Redis()->connect('localhost'))); // Use Redis as Storage

// Alternatives:
//
// $adapter = new PredisAdapter(new \Predis\Predis(['tcp://127.0.0.1:6379'])); // Use Predis as Storage
//
// $memcache = new \Memcached();
// $memcache->addServer('localhost', 11211);
// $adapter = new MemcacheAdapter($memcache);
//
// $adapter = new APCAdapter(); // Use APC as Storage

$key = 'ratelimit';
// $key = 'ratelimit' . ':' .  $_SERVER['REMOTE_ADDR']; // You can append identificator, if you want to narrow your limits to specific ip address or to something else

$rate_limit = new RateLimit($key, 100, 1, $adapter); // 100 requests per second

if ($rate_limit->check(30)) { // Try to consume 30 requests
    // Success
} else {
    // Failed (leaked bucket)
}

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 69.2% 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 ~1 days

Total

3

Last Release

1619d ago

PHP version history (2 changes)0.1PHP &gt;=5.6

0.3PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a06b8e40ba98a6a8698e516bd4398cff79a2df6347bb274396531f9760f9669e?d=identicon)[uliandim](/maintainers/uliandim)

---

Top Contributors

[![juliandimitrov](https://avatars.githubusercontent.com/u/11029398?v=4)](https://github.com/juliandimitrov "juliandimitrov (27 commits)")[![uliandim](https://avatars.githubusercontent.com/u/9256324?v=4)](https://github.com/uliandim "uliandim (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdimitrov-php-ratelimit/health.svg)

```
[![Health](https://phpackages.com/badges/jdimitrov-php-ratelimit/health.svg)](https://phpackages.com/packages/jdimitrov-php-ratelimit)
```

PHPackages © 2026

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