ella123 / hyperf-throttle
hyperf throttle rate limit
3.1.14
2024-05-31 12:42 UTC
Requires
- php: >=8.1
- hyperf/contract: 3.1.*
- hyperf/di: 3.1.*
- hyperf/framework: 3.1.*
- hyperf/http-server: 3.1.*
- hyperf/redis: 3.1.*
- nesbot/carbon: ^3.0|^2.0
- psr/simple-cache: ^1.0|^2.0|^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
- swoole/ide-helper: dev-master
This package is auto-updated.
Last update: 2024-10-31 00:41:12 UTC
README
适配 hyperf 框架的请求频率限流器。
安装依赖
composer require ella123/hyperf-throttle
发布配置
php bin/hyperf.php vendor:publish ella123/hyperf-throttle
注解说明
使用实例
- 支持类
- 支持方法
/** * 频率限制 */ #[\Ella123\HyperfThrottle\Annotation\Throttle(limit: 60,timer: 60)] class A { #[\Ella123\HyperfThrottle\Annotation\Throttle(limit: 60,timer: 60)] public function name() { } } /** * 重复提交 */ #[\Ella123\HyperfThrottle\Annotation\Resubmit(limit: 1,timer: 60)] class B { #[\Ella123\HyperfThrottle\Annotation\Resubmit(limit: 1,timer: 60)] public function submit() { } } /** * 短信限制(支持定义不同规则) */ #[\Ella123\HyperfThrottle\Annotation\SmsMinuteLimit(limit: 1,timer: 60)] #[\Ella123\HyperfThrottle\Annotation\SmsHourLimit(limit: 5,timer: 3600)] #[\Ella123\HyperfThrottle\Annotation\SmsDayLimit(limit: 15,timer: 86400)] class C { #[\Ella123\HyperfThrottle\Annotation\SmsMinuteLimit(limit: 1,timer: 60)] #[\Ella123\HyperfThrottle\Annotation\SmsHourLimit(limit: 5,timer: 3600)] #[\Ella123\HyperfThrottle\Annotation\SmsDayLimit(limit: 15,timer: 86400)] public function send() { } }