switon / throttle
Redis-backed rate limiting for HTTP actions and direct service checks for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- psr/event-dispatcher: ^1.0
- switon/core: ^1.0
- switon/event: ^1.0
- switon/http: ^1.0
- switon/principal: ^1.0
- switon/redis: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Switon's request throttling layer for #[RateLimit] rules, burst-aware windows, and HTTP 429 rejections.
Highlights
- Declarative limits:
#[RateLimit]can be applied to controllers or actions. - Layered rules: class defaults set the baseline, and method rules can override them.
- Programmatic checks: the same limit syntax can be used directly.
- Burst handling: the first window can allow burst tolerance.
- Rejection visibility:
ThrottlingandThrottledsurface the applied window and outcome.
Installation
composer require switon/throttle
Quick Start
use Switon\Throttle\Attribute\RateLimit; #[RateLimit('10/m')] final class ApiController { public function searchAction(): array { return []; } }
Docs: https://docs.switon.dev/latest/throttle
License
MIT.