acidf0x/laravel-ez-throttle
Composer 安装命令:
composer require acidf0x/laravel-ez-throttle
包简介
A simple Laravel Throttle extension
README 文档
README
A simple Laravel Throttle extension
Installation
install using composer:
composer require acidf0x/laravel-ez-throttle
Basic Usage
Start by creating an Throttle instance
use AcidF0x\EzThrottle\Throttle; $throttle = new Throttle(); // or $throttle = new Throttle($throttleKey , $maxAttempts, $decayMinutes); // increase hit count $throttle->hit() if ($throttle->isBlock()) { echo $throttle->getErrorMsg(); // "Too Many Requests. Please try again in 1 minutes" } else { // ... if ( ... ) { $throttle->clear(); } }
or use the EzThrottle trait if you want
use AcidF0x\EzThrottle\Foundation\EzThrottle; class SomeController extends Controller { use EzThrottle; $protected $ThrottleKey = 'LoginThrottle'; $protected $maxAttempts = '3'; $protected $decayMinutes = '1'; public function doLogin() { //..... // increase hit count $this->hit() if ($this->isBlock()) { return $this->getErrorMsg(); // "Too Many Requests. Please try again in 1 minutes" } else { // ... if ( ... ) { $this->clear(); } } //...... } }
Customize
php artisan vendor:publish --provider=AcixF0x\Ezthrrotle\EzthrottleServiceProvider
Localization
# resources/lang/vendor/ezthrottle/en/error.php return [ 'sec'=> 'Too Many Requests. Please try again in :sec seconds', 'min'=> 'Too Many Requests. Please try again in :min minutes', 'hour'=> 'Too Many Requests. Please try again in :hour hours', 'days'=> 'Too Many Requests. Please try again in :day days', ];
Config
# config/ezthrottle.php return [ 'defaultThrottleKey' => 'throttle', 'defaultDecayMinutes' => '1', 'defaultMaxAttempts' => '3' ];
Todos
- change Trait Method
- Test and support Variable Laravel Ver. (5.*)
- Change Composer Dependency
acidf0x/laravel-ez-throttle 适用场景与选型建议
acidf0x/laravel-ez-throttle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 acidf0x/laravel-ez-throttle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 acidf0x/laravel-ez-throttle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-11