quanzo / yii2-recaptchav3
为Yii 2的无痕谷歌reCAPTCHA v3
1.0.2
2019-08-24 05:39 UTC
Requires
- php: >=7.0
- google/recaptcha: ^1.2
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-24 17:18:12 UTC
README
使用Google Recaptcha v3(无痕)保护网站免受垃圾邮件攻击。
需要私有和公开密钥。
安装和连接
- 将其复制到模块文件夹并连接到 autoload.php
- 或者使用composer
php composer.phar require "quanzo/recaptchav3"
或者在项目require部分添加
"quanzo/recaptchav3": "*"
- 在 config.php 中连接
$config = [
'bootstrap' => [
'recaptcha',
],
'modules' => [
'recaptcha' => [
'class' => '\x51\yii2\modules\recaptchav3\Module',
'publicKey' => '...........................',
'privateKey' => '...........................',
'disableForRegisterUser' => true // отключить для зарегистрированных пользователей
],
], // end modules
];
使用方法
if (\Yii::$app->getModule('recaptcha')->validUser()) {
echo ':-)';
} else {
echo ':-(';
}
如果需要禁用检查 - 设置常量 DISABLE_RECAPTCHA