matrozov / yii2-yandex-smart-captcha
Yii2 Yandex Smart Captcha
Installs: 88
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:extension
Requires
- php: >=8.0
- yiisoft/yii2: *
- yiisoft/yii2-httpclient: ^2.0
README
Yii2 Yandex Smart Captcha
Adds Yandex Smart Captcha into yii2 project
Installation
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.
Usage
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) ?>
Additional parameters
YandexSmartCaptcha
Name | Required | Type | Default value | |
---|---|---|---|---|
clientKey | + | string | Read more | |
serverKey | + | string | Read more |
YandexSmartCaptchaValidator
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 |
YandexSmartCaptchaWidget
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 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 |