PHP code example of luyadev / yii2-recaptcha-widget

1. Go to this page and download the library: Download luyadev/yii2-recaptcha-widget library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luyadev / yii2-recaptcha-widget example snippets


'components' => [
    'reCaptcha' => [
        'class' => 'luyadev\recaptcha\ReCaptchaConfig',
        'siteKeyV2' => 'your siteKey v2',
        'secretV2' => 'your secret key v2',
        'siteKeyV3' => 'your siteKey v3',
        'secretV3' => 'your secret key v3',
    ],
    ...

public $reCaptcha;

public function rules()
{
    return [
        [['reCaptcha'], 'ssage' => 'Please confirm that you are not a bot.'],
    ];
}

public $reCaptcha;

public function rules()
{
    return [
        [['reCaptcha'], '=> 0.5, 'action' => 'homepage'],
    ];
}

$form->field($model, 'reCaptcha')->widget(\luyadev\recaptcha\ReCaptcha2::class) // v2

$form->field($model, 'reCaptcha')->widget(\luyadev\recaptcha\ReCaptcha3::class, ['action' => 'homepage']) // v3

\luyadev\recaptcha\ReCaptcha2::widget([
    'name' => 'reCaptcha',
    'widgetOptions' => ['class' => 'col-sm-offset-3'],
]);

\luyadev\recaptcha\ReCaptcha3::widget([
    'name' => 'reCaptcha',
    'action' => 'homepage',
    'widgetOptions' => ['class' => 'col-sm-offset-3'],
]);