Adds Yandex Smart Captcha into yii2 project
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist matrozov/yii2-yandex-smart-captcha "*"
or add
"matrozov/yii2-yandex-smart-captcha": "*"
to the require section of your composer.json file.
Once the extension is installed, simply use it in your code by:
add this to your components main.php
'components' => [
...
'yandexSmartCaptcha' => [
'class' => 'matrozov\yii2yandexSmartCaptcha\YandexSmartCaptcha',
'serverKey' => 'ysc2_********',
'clientKey' => 'ysc1_********',
],and in your model
public $yandexSmartCaptcha;
public function rules()
{
return [
...
[['yandexSmartCaptcha'], \matrozov\yii2yandexSmartCaptcha\YandexSmartCaptchaValidator::class],
];
}<?= $form->field($model, 'yandexSmartCaptcha')->widget(\matrozov\yii2yandexSmartCaptcha\YandexSmartCaptchaWidget::class) ?>| Name | Required | Type | Default value | |
|---|---|---|---|---|
| clientKey | + | string | Read more | |
| serverKey | + | string | Read more |
| Name | Required | Type | Default value | Comment |
|---|---|---|---|---|
| host | string | bool | false | Specify host for validate smart captcha response or set true to get host from request Read more |
|
| sendUserIp | bool | true | IP address of the user that originated the request to validate the token. Read more |
| Name | Required | Type | Default value | Comment |
|---|---|---|---|---|
| hl | string | null | null By default language get from app language |
Widget and challenge language. Allowed languages: ru, en, be, kk, tt, uk, uz, tr An explicitly set language outside of that list throws InvalidConfigException. When the language is taken from the app (hl is null), the region part is dropped (ru-RU -> ru) and an unsupported app language falls back to en.Read more |
|
| test | bool | false | Running CAPTCHA in test mode. The user will always get a challenge. Use this property for debugging and testing only. Read more |
|
| webView | bool | false | Running CAPTCHA in WebView. You can use it to make user response validation more precise when adding CAPTCHA to mobile apps via WebView. Read more |
|
| invisible | bool | false | Invisible CAPTCHA is a way of connecting the SmartCaptcha widget without the "I’m not a robot" button on the page. Read more |
|
| shieldPosition | string | top-left | Position of the data processing notice section. Allowed positions: top-left, center-left, bottom-left, top-right, center-right, bottom-right Read more |
|
| hideShield | bool | false | Hide the data processing notice section. Read more |