PHPackages                             coon-design/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. [HTTP &amp; Networking](/categories/http)
4. /
5. coon-design/rate-limit

ActiveLibrary[HTTP &amp; Networking](/categories/http)

coon-design/rate-limit
======================

PSR-7 rate limit implementation

0.6(1y ago)055MITPHPPHP ^8

Since Jun 1Pushed 1y agoCompare

[ Source](https://github.com/startailcoon/rate-limit)[ Packagist](https://packagist.org/packages/coon-design/rate-limit)[ Docs](https://github.com/startailcoon/rate-limit)[ RSS](/packages/coon-design-rate-limit/feed)WikiDiscussions master Synced 1mo ago

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

Rate-limit
==========

[](#rate-limit)

PSR-7 Rate limiting using Redis or Memcache. predis is not needed for this middleware. It uses Tinyredisclient by ptrofimov.

Usage
-----

[](#usage)

The last constructor argument is the redis password. This is option. When it is not provided the middleware will connect without authenticating.

```
$rateLimitMiddleware = new \Prezto\RateLimit\RateLimitMiddleware('10.241.25.226', '6379', 'aslkjkrnflawekrmgfslerm')
```

Setting the limit after instantiating. The first argument is the maximum number of requests. The second argument is the time limit in seconds.

In this example the client is allowed to make 60 requests in 30 seconds.

```
$rateLimitMiddleware->setRequestsPerSecond(60, 30);
```

When the request limit has been reached the request statuscode is set to 429 by default.

By default the Redis is used as a storage. To use Memcache instead:

```
$rateLimitMiddleware->useMemcache();
```

Custom handler when limit has been reached.
-------------------------------------------

[](#custom-handler-when-limit-has-been-reached)

```
$rateLimitMiddleware->setHandler(function ($request, $response) {
            $response = $response->withStatus(429);
            $response->getBody()->write("Rate limit reached.");
            return $response;
        });
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance40

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 56.3% 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 ~286 days

Total

3

Last Release

506d ago

PHP version history (2 changes)0.4PHP &gt;=5.4.0

0.6PHP ^8

### Community

Maintainers

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

---

Top Contributors

[![startailcoon](https://avatars.githubusercontent.com/u/12114550?v=4)](https://github.com/startailcoon "startailcoon (9 commits)")[![ironsmile](https://avatars.githubusercontent.com/u/50431?v=4)](https://github.com/ironsmile "ironsmile (7 commits)")

---

Tags

psr-7middlewarerate limit

### Embed Badge

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

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

###  Alternatives

[league/uri

URI manipulation library

1.1k206.4M277](/packages/league-uri)[psr/http-server-middleware

Common interface for HTTP server-side middleware

18091.2M1.5k](/packages/psr-http-server-middleware)[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[tuupola/slim-basic-auth

PSR-7 and PSR-15 HTTP Basic Authentication Middleware

4442.0M26](/packages/tuupola-slim-basic-auth)[relay/relay

A PSR-15 server request handler.

3302.1M86](/packages/relay-relay)[tuupola/cors-middleware

PSR-7 and PSR-15 CORS middleware

1331.8M24](/packages/tuupola-cors-middleware)

PHPackages © 2026

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