kekaadrenalin/yii2-module-recaptcha-v3 This is reCAPTCHA v3 for Yii2.

Total Downloads

Yii2 reCAPTCHA v3

  1. Installation
  2. Usage
  3. For tests

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 kekaadrenalin/yii2-module-recaptcha-v3 "*"

or add

"kekaadrenalin/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'      => 'kekaadrenalin\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'], \kekaadrenalin\recaptcha3\ReCaptchaValidator::className(), 'acceptance_score' => 0]
 	];
}
<?= $form->field($model, 'reCaptcha')->widget(\kekaadrenalin\recaptcha3\ReCaptchaWidget::class) ?>

For tests

When use `YII_ENV_TESTinindex-test.phpthen disabled recaptcha's validate:php defined('YII_ENV') or define('YII_ENV', 'test'); `

1 0
2 followers
33 120 downloads
Yii Version: 2.0
License: BSD-3-Clause
Category: Validation
Tags: recaptcha
Developed by: kekaadrenalin
Created on: Oct 21, 2019
Last updated: 4 years ago
Packagist Profile
Github Repository

Related Extensions