PHPackages                             kelunik/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. [Caching](/categories/caching)
4. /
5. kelunik/rate-limit

ActiveLibrary[Caching](/categories/caching)

kelunik/rate-limit
==================

Rate Limiting for Amp.

v3.0.0(2y ago)13324↑50%1MITPHPPHP &gt;=8.1

Since Apr 25Pushed 2y ago2 watchersCompare

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

READMEChangelog (3)Dependencies (4)Versions (5)Used By (1)

rate-limit
==========

[](#rate-limit)

[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)

`kelunik/rate-limit` is a rate limiting library for [Amp](https://github.com/amphp/amp).

Installation
------------

[](#installation)

```
composer require kelunik/rate-limit
```

Usage
-----

[](#usage)

You're in full control of any actions when the rate limit is exceeded. You can also already warn the user before he exceeds the limit.

```
$current = $this->rateLimit->increment("{$userId}:{$action}");

if ($current > $this->limit) {
    // show captcha or error page or do anything you want
} else {
    // request is within the limit, continue normally
}
```

If you want to expose the limits, e.g. in an HTTP API, you can also request the reset time for a given key.

```
$current = $this->rateLimit->increment("{$userId}:{$action}");

$response->setHeader("x-ratelimit-limit", $this->limit);
$response->setHeader("x-ratelimit-remaining", $this->limit - $current);
$response->setHeader("x-ratelimit-reset", $this->rateLimit->getTtl("{$userId}:{$action}"));
```

`RateLimit::getTtl()` returns the seconds until the limit is reset. If you want to return the absolute time, you can just add `time()` to that value.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity75

Established project with proven stability

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

Total

4

Last Release

1034d ago

Major Versions

v1.0.0 → v2.0.02017-08-05

v2.0.0 → v3.0.02023-09-04

PHP version history (2 changes)v2.0.0PHP &gt;=7

v3.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/12852217f3369e8144bc9ce6ac2a2341c28c5512c5b3df5749bfbbd45b6877ff?d=identicon)[kelunik](/maintainers/kelunik)

---

Top Contributors

[![kelunik](https://avatars.githubusercontent.com/u/2743004?v=4)](https://github.com/kelunik "kelunik (11 commits)")

---

Tags

amphpphprate-limitredisampamphprate limitlimit

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k325.4M2.8k](/packages/predis-predis)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

167714.3k59](/packages/amphp-redis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k40.9M75](/packages/snc-redis-bundle)[nikolaposa/rate-limit

General purpose rate limiter implementation.

2741.7M3](/packages/nikolaposa-rate-limit)[clue/redis-protocol

A streaming Redis protocol (RESP) parser and serializer written in pure PHP.

5216.6M14](/packages/clue-redis-protocol)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23617.1k1](/packages/rtcamp-nginx-helper)

PHPackages © 2026

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