vintage/yii2-invisible-recaptcha

Facade of Invisible reCAPTCHA by Google for Yii2 Framework

v1.0.1 2019-10-25 12:49 UTC

This package is not auto-updated.

Last update: 2024-04-14 02:47:30 UTC


README

68747470733a2f2f7777772e677374617469632e636f6d2f696d616765732f69636f6e732f6d6174657269616c2f70726f647563742f32782f7265636170746368615f343864702e706e67

Invisible reCAPTCHA


Facade of Invisible reCAPTCHA by Google for Yii2 Framework. For more info read official documentation.

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version

Installation

Install package

Run command

$ composer require vintage/yii2-invisible-recaptcha

or add

"vintage/yii2-invisible-recaptcha": "~1.0"

to the require section of your composer.json.

Usage

  1. Creates API key in your Google Account

  2. Configure API keys in frontend/config/params-local.php

<?php

use vintage\recaptcha\helpers\RecaptchaConfig;

return [
    RecaptchaConfig::SITE_KEY => 'your_site_key',
    RecaptchaConfig::PRIVATE_KEY => 'your_private_key',
];
  1. Call widget in form
<form id="send-feedbacl-js" method="post">
<?= \vintage\recaptcha\widgets\InvisibleRecaptcha::widget([
    'formSelector' => '#send-feedback-js',
]) ?>
<button type="submit">Send</button>
</form>
  1. Validate in backend
\vintage\recaptcha\validators\InvisibleRecaptchaValidator::validateInline(
    Yii::$app->getRequest()->post()
);

or if you want to handle the errors

$validator = new \vintage\recaptcha\validators\InvisibleRecaptchaValidator(
    Yii::$app->getRequest()->post()
);
if (!$validator->validate()) {
    return $validator->getErrors();
}

Configuration

Widget configuration options.

Option Description Type Default
options Html options for recaptcha container array ['data-badge' => 'inline', 'data-size' => 'invisible']
formSelector Html form selector string 'form.invisible-recaptcha-js'
callback Callback JS function. Calls after captcha was successfully passed string 'triggerReCaptcha'
siteKey API site key string -

License

License

This project is released under the terms of the BSD-3-Clause license.

Copyright (c) 2017, Vintage Web Production