PHP code example of alikdex / yii2-recaptcha

1. Go to this page and download the library: Download alikdex/yii2-recaptcha 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/ */

    

alikdex / yii2-recaptcha example snippets


'components' => [
    'container' => [
        'definitions' => [
            Adx\ReCaptcha\ReCaptcha::class => [
                'siteKey' => 'Your site key',
            ],
            Adx\ReCaptcha\ReCaptchaValidator::class => [
                'secret' => 'Your secret key',
            ],
        ],
    ],
    ...
],

public $reCaptcha;

public function rules()
{
  return [
      // ...
      [['captcha'], \Adx\ReCaptcha\ReCaptchaValidator::class],
  ];
}

public function rules()
{
  return [
      // ...
      [[], \Adx\ReCaptcha\ReCaptchaValidator::class],
  ];
}

<?= \Adx\ReCaptcha\ReCaptcha::widget([
    'name' => 'captcha', // optional
    'widgetOptions' => [
      'class' => 'col-sm-offset-3',
      'data-theme' => 'dark',
      // ...  see google recaptcha2 manual
    ]
]) 

<?= $form->field($model, 'captcha')->widget(\Adx\ReCaptcha\ReCaptcha::class) 

<?= \Adx\ReCaptcha\ReCaptcha::widget() 

php composer.phar