Download the PHP package ez-php/rate-limiter without Composer
On this page you can find all versions of the php package ez-php/rate-limiter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ez-php/rate-limiter
More information about ez-php/rate-limiter
Files in ez-php/rate-limiter
Package rate-limiter
Short Description Rate limiter module for the ez-php framework — array, Redis, and cache-backed drivers with ThrottleMiddleware
License MIT
Homepage https://github.com/ez-php/rate-limiter
Informations about the package rate-limiter
ez-php/rate-limiter
Request throttling for ez-php applications — three backends, a unified interface, and a plug-in ThrottleMiddleware.
Installation
Drivers
| Driver | Persistence | External requirement | Concurrency-safe |
|---|---|---|---|
ArrayDriver |
In-process (lost on restart) | None | No — single-process/test use only |
RedisDriver |
Redis | ext-redis |
Yes — atomic INCR |
CacheDriver |
Delegates to ez-php/cache |
Any configured cache driver | Driver-dependent |
Warning:
ArrayDriveruses a plain PHP array without atomic operations. Concurrent requests (e.g. PHP-FPM workers) can race and both be allowed through simultaneously. UseRedisDriverorCacheDriverin production.
Basic usage
ThrottleMiddleware
Plug into the framework middleware pipeline for per-IP global or per-route throttling:
The middleware:
- Resolves the client IP from
X-Forwarded-For(first value) or falls back toREMOTE_ADDR. - Returns HTTP 429 with body
Too Many Requestswhen the limit is exceeded. - Adds
X-RateLimit-LimitandX-RateLimit-Remainingheaders on every passing response.
Service provider
Register RateLimiterServiceProvider in provider/modules.php:
Create config/rate_limiter.php:
Interface
License
MIT
All versions of rate-limiter with dependencies
ez-php/contracts Version ^1.0
ez-php/http Version ^1.0
ez-php/cache Version ^1.0