lesha724/yii2-math-captcha

mathСaptcha in yii2

Installs: 4 354

Dependents: 3

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

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

This package is auto-updated.

Last update: 2024-04-29 04:01:49 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(); ?>