developit/yii2-captcha

yii2 验证码

安装次数: 16,483

依赖: 0

建议者: 0

安全: 0

星星: 9

关注者: 3

分支: 2

开放问题: 0

类型:yii2 扩展

1.2 2017-09-05 17:50 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:23:03 UTC


README

支持识别阿拉伯语和波斯数字的yii2验证码。

screenshot

安装

安装此扩展的首选方式是通过 composer

运行以下命令:

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

或者在你的 composer.json 文件的 require 部分添加以下内容:

"developit/yii2-captcha": "*"

使用方法

安装扩展后,只需修改你的控制器,添加或更改 actions() 方法。

    public function actions()
    {
        $this->layout = $this->setting['layout'];
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
            'captcha' => [
                'class' => 'developit\captcha\CaptchaAction',
                'type' => 'numbers', // 'numbers', 'letters' or 'default' (contains numbers & letters)
                'minLength' => 4,
                'maxLength' => 4,
            ],
        ];
    }

视图

use developit\captcha\Captcha;
<?=
$form->field($model, 'verifyCode')->widget(Captcha::className())
?>