PHP code example of himiklab / yii2-recaptcha-widget
1. Go to this page and download the library: Download himiklab/yii2-recaptcha-widget 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/ */
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.'],
];
}
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',
],
];
}
<?= $form->field($model, 'reCaptcha')->widget(
\himiklab\yii2\recaptcha\ReCaptcha2::className(),
[
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
]
)
<?= $form->field($model, 'reCaptcha')->widget(
\himiklab\yii2\recaptcha\ReCaptcha3::className(),
[
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
'action' => 'homepage',
]
)
<?= \himiklab\yii2\recaptcha\ReCaptcha2::widget([
'name' => 'reCaptcha',
'siteKey' => 'your siteKey', // unnecessary is reCaptcha component was set up
'widgetOptions' => ['class' => 'col-sm-offset-3'],
])
<?= \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'],
])
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.