【文件属性】:
文件名称:think-throttle:thinkphp6.0 限制访问频率的中间件
文件大小:13KB
文件格式:ZIP
更新时间:2021-05-23 18:37:52
PHP
安装
composer require topthink/think-throttle
安装后会自动为项目生成 conf/throttle.php 配置文件,安装后组件不会自动启用,需要手动设置。
开启
组件以中间件的方式进行工作,因此它的开启与其他中间件一样,例如在全局中间件中使用 app/middleware.php :
<?php
return [
\think\middleware\Throttle::class,
];
配置说明
在 config/throttle.php 配置选项:
<?php
// 中间件配置
return [
// 缓存键前缀,防止键值与其他应用冲突
'prefix' => 'throttle_',
// 缓存的键,true 表示使用来源ip
'key' => true,
// 要被限制的请求类型, eg: G
【文件预览】:
think-throttle-master
----composer.json(602B)
----LICENSE(11KB)
----src()
--------config.php(822B)
--------Throttle.php(6KB)
--------throttle()
----.gitignore(27B)
----README.md(3KB)