Yii2-recaptcha-widget (Archive de google - reCaptcha)

Yii2-recaptcha-widget (Archive de google - reCaptcha)

himiklab/yii2-recaptcha-widget

Installer Démo

Yii2-recaptcha-widget (Archive de google - reCaptcha)

Heure de publication: vendredi 10 juillet 2015 (il y a 4 ans)

Créé par: Семенов Александр Сергеевич

Catégorie: Autre

Version actuelle: 2.1.1
14 mai 2019 10:40:36 (il y a 8 mois)

Packagist: himiklab/yii2-recaptcha-widget

: https://github.com/himiklab/yii2-recaptcha-widget

: 461208 (Par mois: 14625)

Type: Компонент


1) Идем в гугл получаем ключи

www.google.com/recaptcha/admin#createsite

Примеры:

Для работы с моделями:

public $reCaptcha; public function rules() { return [ // ... [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your secret key'] ]; } 

Или же просто

public function rules() { return [ // ... [[], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your secret key'] ]; } 

Использование формах:

<?= $form->field($model, 'reCaptcha')->widget( \himiklab\yii2\recaptcha\ReCaptcha::className(), ['siteKey' => 'your siteKey'] ) ?> 

Просто виджет:

<?= \himiklab\yii2\recaptcha\ReCaptcha::widget([ 'name' => 'reCaptcha', 'siteKey' => 'your siteKey', 'widgetOptions' => ['class' => 'col-sm-offset-3'] ]) ?> 

Google reCAPTCHA widget for Yii2

Based on Google reCaptcha API 2.0 and 3.0.

Packagist Packagist license

Upgrade to 2.x version

Warning! Classes ReCaptcha and ReCaptchaValidator is deprecated. Please replace their to ReCaptchaConfig, ReCaptcha2 and ReCaptchaValidator2.

Installation

The preferred way to install this extension is through composer.

  • Either run
php composer.phar require --prefer-dist "himiklab/yii2-recaptcha-widget" "*"

or add

"himiklab/yii2-recaptcha-widget" : "*"

to the require section of your application’s composer.json file.

  • Sign up for an reCAPTCHA API keys.

  • Configure the component in your configuration file (web.php). The parameters siteKey and secret are optional. But if you leave them out you need to set them in every validation rule and every view where you want to use this widget. If a siteKey or secret is set in an individual view or validation rule that would overrule what is set in the config.

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

or use DI container:

'container' => [
    'definitions' => [
        himiklab\yii2\recaptcha\ReCaptcha2::className() => function ($container, $params, $config) {
            return new himiklab\yii2\recaptcha\ReCaptcha2(
                'your siteKey v2',
                '', // default
                $config
            );
        },
        himiklab\yii2\recaptcha\ReCaptchaValidator2::className() => function ($container, $params, $config) {
            return new himiklab\yii2\recaptcha\ReCaptchaValidator2(
                'your secret key v2',
                '', // default
                null, // default
                null, // default
                $config
            );
        },
    ],
],
  • Add ReCaptchaValidator2 or ReCaptchaValidator3 in your model, for example:

v2

public $reCaptcha;

public function rules()
{
  return [
      // ...
      [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator2::className(),
        'secret' => 'your secret key', // unnecessary if reСaptcha is already configured
        'uncheckedMessage' => 'Please confirm that you are not a bot.'],
  ];
}

v3

public $reCaptcha;

public function rules()
{
  return [
      // ...
      [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator3::className(),
        'secret' => 'your secret key', // unnecessary if reСaptcha is already configured
        'threshold' => 0.5,
        'action' => 'homepage',
      ],
  ];
}

Usage

For example:

v2

<?= $form->field($model, 'reCaptcha')->widget(
    \himiklab\yii2\recaptcha\ReCaptcha2::className(),
    [
        'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
    ]
) ?>

v3

<?= $form->field($model, 'reCaptcha')->widget(
    \himiklab\yii2\recaptcha\ReCaptcha3::className(),
    [
        'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
        'action' => 'homepage',
    ]
) ?>

or

v2

<?= \himiklab\yii2\recaptcha\ReCaptcha2::widget([
    'name' => 'reCaptcha',
    'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
    'widgetOptions' => ['class' => 'col-sm-offset-3'],
]) ?>

v3

<?= \himiklab\yii2\recaptcha\ReCaptcha3::widget([
    'name' => 'reCaptcha',
    'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
    'action' => 'homepage',
    'widgetOptions' => ['class' => 'col-sm-offset-3'],
]) ?>
  • NOTE: Please disable ajax validation for ReCaptcha field!

Resources


Комментарий:
reCaptcha от гугл, супер удобное и надежное решение.

Достоинства:
Надежная, зачастую упрощает жизнь пользователя и не спрашивает дополнительных вопросов (гугл знает все о тебе).

Недостатки:
Недостатков не выявлено.


Affichage de 1-1 sur 1 élément.

Tous les commentaires (0)
Sans commentaires

dev-master — 27 juin 2019 20:51:28 (il y a 6 mois)

2.1.1 — 14 mai 2019 10:40:36 (il y a 8 mois)

2.1.0 — 12 mai 2019 15:26:01 (il y a 8 mois)

2.0.0 — 15 avr. 2019 10:18:47 (il y a 9 mois)

1.2.2 — 8 nov. 2018 12:49:58 (il y a un an)

1.2.1 — 3 juil. 2018 16:34:52 (il y a un an)

1.2.0 — 3 avr. 2018 11:17:47 (il y a un an)

1.1.2 — 27 févr. 2018 15:55:43 (il y a un an)

1.1.1 — 25 janv. 2018 19:15:09 (il y a un an)

1.1.0 — 10 janv. 2018 14:22:28 (il y a 2 ans)

1.0.7 — 8 nov. 2017 19:56:06 (il y a 2 ans)

1.0.6 — 10 janv. 2017 18:46:29 (il y a 3 ans)

1.0.5 — 10 juin 2016 18:38:28 (il y a 3 ans)

Стандартная установка:

Добавьте composer.json файл вашего проекта:

"himiklab/yii2-recaptcha-widget": "*"

Запустите обновление зависимостей


Читать про обнолвение SkeekS CMS