1. Go to this page and download the library: Download yiirocks/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/ */
use Yiisoft\FormModel\FormModel;
use YiiRocks\Recaptcha\RecaptchaV2Field;
use YiiRocks\Recaptcha\RecaptchaV2Theme;
use YiiRocks\Recaptcha\RecaptchaV2Size;
use YiiRocks\Recaptcha\RecaptchaV2Type;
echo RecaptchaV2Field::field($form, 'captcha')
->withTheme(RecaptchaV2Theme::Dark)
->withSize(RecaptchaV2Size::Compact)
->withType(RecaptchaV2Type::Audio)
->withId('my-captcha')
->withCallback('onSuccess')
->render();
use Yiisoft\FormModel\FormModel;
use YiiRocks\Recaptcha\RecaptchaV3Field;
use YiiRocks\Recaptcha\RecaptchaV3Badge;
echo RecaptchaV3Field::field($form, 'captcha')
->withAction('login')
->withFormId('login-form')
->withBadge(RecaptchaV3Badge::Hidden)
->render();
use YiiRocks\Recaptcha\RecaptchaV2Rule;
final class ContactForm
{
#[RecaptchaV2Rule]
public string $gRecaptchaResponse = '';
}
use YiiRocks\Recaptcha\RecaptchaV3Rule;
final class LoginForm
{
#[RecaptchaV3Rule(
threshold: 0.5,
action: 'login',
)]
public string $gRecaptchaResponse = '';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.