integready / yii2-simplemath-captcha
Simple Math Captcha
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 5
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-12-29 04:59:22 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist integready/yii2-simplemath-captcha "dev-master"
or add
"integready/yii2-simplemath-captcha": "dev-master"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply modify your controler, add or change methode actions()
:
public function actions() { return [ ... 'captcha' => [ 'class' => 'integready\simplemathcaptcha\CaptchaAction', 'operators' => ['+','-','*'], 'maxValue' => 10, 'fontSize' => 18, ], ]; }
In view
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ 'template' => '<div class="row"><div class="col-lg-2">{image}</div><div class="col-lg-10">{input}</div></div>', ])->hint('Hint: click on the equation to refresh') ?>
In config/web.php
'rules' => [ 'site/captcha/<refresh:\d+>' => 'site/captcha', 'site/captcha/<v:\w+>' => 'site/captcha', ]