lesha724/yii2-math-captcha

mathСaptcha in yii2

Maintainers

👁 lesha724

Package info

github.com/lesha724/yii2-math-captcha

Type:yii2-extension

pkg:composer/lesha724/yii2-math-captcha

Statistics

Installs: 10 330

Dependents: 2

Suggesters: 0

Stars: 2

Open Issues: 0

v0.1.2 2018-04-02 08:31 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 3b20309b8220426d6a580a13b392afb8225de32c

  • lesha724 <neff.alexey.woop@gmail.com>

extensionyii2 widget captchamath-captcha

This package is auto-updated.

Last update: 2026-06-29 01:20:53 UTC


README

виджет math-captcha

👁 Пример

Установка

Предпочтительным способом установки этого расширения является composer.

Выполните

php composer.phar require --prefer-dist lesha724/yii2-math-captcha "*"

или добавьте

"lesha724/yii2-math-captcha": "*"

в блок require в вашем composer.json файле.

Использование

Как только расширение будет установлено, просто используйте его в своем коде :

use yii\web\Controller;

class SiteController extends Controller
{
 public function actions()
 {
 return [
 ...
 'captcha' => [
 'class' => 'lesha724\MathCaptcha\MathCaptchaAction',
 //'imageLibrary'=>'imagick', only 'gd' and 'imagick' 
 'fixedVerifyCode' => YII_ENV_TEST ? '42' : null,
 //не задавайте значение foreColor и backColor (они заполняться случайными цветами)
 //остльные опции http://www.yiiframework.com/doc-2.0/yii-captcha-captchaaction.html
 ],
 ];
 }
}
<?php $form = ActiveForm::begin([]); ?>

....

<?= $form->field($model, 'verifyCode')->widget(\yii\captcha\Captcha::className(), [
	'template' => '{image} {input}',
]) ?>

....

<?php ActiveForm::end(); ?>