lesha724/yii2-math-captcha

yii2中的mathСaptcha

安装次数: 5,003

依赖者: 2

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 1

开放问题: 0

类型:yii2-extension

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

This package is auto-updated.

Last update: 2024-08-29 05:07:44 UTC


README

math-captcha 小部件

Пример

安装

安装此扩展的首选方法是 composer.

执行以下操作

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

或添加

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

到您的 composer.json 文件中的 require 块。

使用

一旦扩展安装完成,只需在您的代码中使用它即可

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 (они заполняться случайными цветами)
                //остльные опции https://yiiframework.cn/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(); ?>