alexleonnovak / yii2-module-recaptcha-v3
This is reCAPTCHA v3 for Yii2. Fork from kekaadrenalin/yii2-module-recaptcha-v3
Installs: 63
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 14
Type:yii2-extension
Requires
- ext-curl: *
- yiisoft/yii2: ~2.0.15
This package is auto-updated.
Last update: 2024-11-17 13:19:35 UTC
README
Note
This is fork from kekaadrenalin/yii2-module-recaptcha-v3
Yii2 reCAPTCHA v3
Adds recaptcha-v3 into yii2 project
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist alexleonnovak/yii2-module-recaptcha-v3 "*"
or add
"alexleonnovak/yii2-module-recaptcha-v3": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
add this to your components main.php
'components' => [ ... 'reCaptcha3' => [ 'class' => 'alexleonnovak\recaptcha3\ReCaptcha', 'site_key' => 'site_key_###', 'secret_key' => 'secret_key_###', ],
and in your model
acceptance_score the minimum score for this request (0.0 - 1.0) or null
public $reCaptcha; public function rules() { return [ ... [['reCaptcha'], \alexleonnovak\recaptcha3\ReCaptchaValidator::className(), 'acceptance_score' => 0] ]; }
<?= $form->field($model, 'reCaptcha')->widget(\alexleonnovak\recaptcha3\ReCaptchaWidget::class) ?>
For tests
When use YII_ENV_TEST
in index-test.php
then disabled recaptcha's validate:
defined('YII_ENV') or define('YII_ENV', 'test');