php-http/throttle-plugin
PSR-7/PSR-18 HTTP client plugin that throttles outgoing requests to control rate and concurrency. Useful for API clients that must respect provider limits, avoid burst traffic, and smooth request flow.
php-http/throttle-plugin integrates with symfony/rate-limiter to enforce rate limits on HTTP requests, making it ideal for APIs, microservices, or applications requiring request throttling (e.g., public APIs, abuse prevention, or tiered access control).Illuminate\Http\Request, middleware) and Symfony’s ecosystem compatibility (via symfony/rate-limiter) enable seamless integration with existing Laravel middleware or service containers.ThrottleRequests middleware).symfony/rate-limiter (v2+), php-http/message (for PSR-7 messages).Illuminate/Http or Psr\Http\Message interfaces (if using PSR-15 middleware).symfony/rate-limiter v2+ may introduce breaking changes if Laravel’s ecosystem lags (e.g., Symfony 6+ components).composer.json and test against Laravel’s supported Symfony versions (e.g., Symfony 5.x for Laravel 9/10).symfony/rate-limiter with a distributed backend (e.g., Symfony\Component\RateLimiter\Storage\RedisStorage).ThrottleRequests middleware (e.g., duplicate headers like X-RateLimit-Limit).app/Http/Kernel.php or use Laravel’s Middleware facade.php-http/throttle-plugin services (e.g., RateLimiter, Storage) to Laravel’s container for dependency injection.Route::middleware([ThrottlePlugin::class])) or per-route.symfony/http-foundation bridge can handle PSR-7 messages, but explicit type hints may be needed for php-http/message objects.ThrottleRequests, evaluate if this plugin’s features justify the added complexity.ThrottleRequests middleware, custom rate limiters).Retry-After) and behavior with Laravel’s native solution.symfony/rate-limiter backends.Symfony\Component\HttpFoundation or PSR-15 middleware (e.g., Laravel\Pipeline\Pipeline).GuzzleHttp or Symfony\Component\HttpClient unless configured to use PSR-7.composer require php-http/throttle-plugin symfony/rate-limiter.config/services.php.// app/Http/Kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\ThrottlePlugin::class,
],
];
RateLimiter or create custom storage adapters for Laravel’s cache system.symfony/rate-limiter for breaking changes (e.g., new storage interfaces).max:100/minute) should be externalized (e.g., database or config files) for easy updates.Log facade) for observability.Symfony\Component\RateLimiter\Storage\MemoryStorage) for non-critical paths.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Redis/Memcached outage | All rate limits disabled | Fallback to in-memory storage (with warnings) |
| Middleware misconfiguration | Incorrect throttling (e.g., 429s) | Validation in middleware constructor |
| Rate limiter backend saturation | High latency or timeouts | Queue-based throttling or dynamic rate scaling |
| Plugin version incompatibility | Breaking changes in Laravel/Symfony | Strict version pinning in composer.json |
X-RateLimit-* headers).ThrottleRequests./health).How can I help you explore Laravel packages today?