PHPackages                             componenta/http-throttle-middleware - 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. componenta/http-throttle-middleware

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

componenta/http-throttle-middleware
===================================

Rate limiting PSR-15 middleware for Componenta

v1.0.0(1mo ago)01MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/componenta/http-throttle-middleware)[ Packagist](https://packagist.org/packages/componenta/http-throttle-middleware)[ RSS](/packages/componenta-http-throttle-middleware/feed)WikiDiscussions main Synced 1w ago

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

Componenta HTTP Throttle Middleware
===================================

[](#componenta-http-throttle-middleware)

PSR-15 fixed-window rate limiting middleware. It limits requests per key and adds rate limit headers to successful responses or returns `429 Too Many Requests`.

Use this package when an HTTP pipeline needs a simple fixed-window request limit by client IP, user id, API key, or another application-defined key.

Boundary
--------

[](#boundary)

This package only enforces request rate limits. It does not authenticate users, resolve trusted proxy headers, or provide a global config provider. If the application runs behind a proxy, place `componenta/http-trusted-proxy-middleware` before this middleware so the `client_ip` request attribute is available.

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

[](#installation)

```
composer require componenta/http-throttle-middleware
```

This package has no config provider. Register a limiter and middleware explicitly.

Limiters
--------

[](#limiters)

ClassStorage`CacheRateLimiter`PSR-16 cache.`FileRateLimiter`Filesystem directory.Both implement `RateLimiterInterface::hit(string $key, int $limit, int $window): RateLimitResult`.

`CacheRateLimiter` works with any PSR-16 cache, but PSR-16 does not provide atomic increments. Under high concurrency a few extra requests can pass through between read and write. Use a backend-specific limiter if strict atomicity is required.

`FileRateLimiter` stores one lock-protected file per key in a writable directory. If it cannot open or lock a file, it fails open and allows the request instead of breaking the application request.

`RateLimitResult` contains:

PropertyMeaning`allowed`Whether the request may continue.`limit`Maximum requests in the current window.`remaining`Remaining requests in the current window.`retryAfter`Seconds until the window resets.Middleware
----------

[](#middleware)

```
use Componenta\Http\Middleware\Throttle\ThrottleMiddleware;

$middleware = new ThrottleMiddleware(
    limiter: $limiter,
    responseFactory: $responseFactory,
    limit: 60,
    window: 60,
);
```

By default the key is `client_ip` request attribute or `REMOTE_ADDR`. A custom key resolver can use user id, API key, or another identifier.

Per-route overrides can be passed through the `rate_limit` request attribute with `limit` and `window` keys.

```
$request = $request->withAttribute(ThrottleMiddleware::ATTR_RATE_LIMIT, [
    'limit' => 10,
    'window' => 60,
]);
```

Successful responses receive `X-RateLimit-Limit` and `X-RateLimit-Remaining` headers. Rejected responses have status `429`, body `429 Too Many Requests`, and headers `Retry-After`, `X-RateLimit-Limit`, and `X-RateLimit-Remaining: 0`.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

43d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20490712?v=4)[Andrey Shelamkoff](/maintainers/Shelamkoff)[@Shelamkoff](https://github.com/Shelamkoff)

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

### Embed Badge

![Health badge](/badges/componenta-http-throttle-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/componenta-http-throttle-middleware/health.svg)](https://phpackages.com/packages/componenta-http-throttle-middleware)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M163](/packages/algolia-algoliasearch-client-php)[hyperf/hyperf

A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.

6.9k3.3k2](/packages/hyperf-hyperf)[mimmi20/browser-detector

Library to detect Browsers and Devices

48157.6k5](/packages/mimmi20-browser-detector)

PHPackages © 2026

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