alex290/yii2-module-recaptcha-v3

这是为Yii2设计的reCAPTCHA v3。

1.0.0 2019-03-22 07:18 UTC

This package is auto-updated.

Last update: 2024-09-12 21:30:41 UTC


README

Yii2 reCAPTCHA v3

安装

安装此扩展的首选方式是 composer

运行

php composer.phar require --prefer-dist alex290/yii2-module-recaptcha-v3 "*"

"alex290/yii2-module-recaptcha-v3": "*"

在您的 composer.json 文件的 require 部分

使用

安装扩展后,只需在代码中使用它即可

将其添加到 main.php 的主要组件中

'components' => [
    ...
    'reCaptcha3' => [
        'class'      => 'alex290\recaptcha3\ReCaptcha',
        'site_key'   => 'site_key_###',
        'secret_key' => 'secret_key_###',
    ],

并在您的模型中

acceptance_score 为此请求的最小分数(0.0 - 1.0)或 null

public $reCaptcha;
 
public function rules()
{
 	return [
 		...
 		 [['reCaptcha'], \alex290\recaptcha3\ReCaptchaValidator::className(), 'acceptance_score' => 0]
 	];
}
<?= $form->field($model, 'reCaptcha')->widget(\alex290\recaptcha3\ReCaptchaWidget::class) ?>