承接 long399/yii2-math-captcha 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

long399/yii2-math-captcha

最新稳定版本:0.1.2

Composer 安装命令:

composer require long399/yii2-math-captcha

包简介

yii2 MathCaptchaAction

README 文档

README

Total Downloads License

MathCaptchaAction for Yii Framework 2.0

Screenshot

Installation

The preferred way to install this extension is through composer. Either run

 composer require --prefer-dist long399/yii2-math-captcha

or add

"long399/yii2-math-captcha": "~0.1"

to the require section of your composer.json file.

Available operations

  1. Addition.
  2. Subtraction.
  3. Multiplication.

Default addition or subtraction operation will be used randomly.

Usage

controller:

public function actions()
{
    return [
        ...
        'captcha' => [
            'class' => \long399\captcha\MathCaptchaAction::class,
            'fixedVerifyCode' => YII_ENV_TEST ? '399' : null,
            'minLength' => 0,
            'maxLength' => 1000,
        ],
        ...
    ];
}

model:

class MyModel extends \yii\db\ActiveRecord
{
    public $captcha;
    ...
    public function rules()
    {
        return [
            ...
            ['captcha', 'captcha', 'captchaAction' => '/site/captcha'],
            ...
        ];
    }
    ...
}

view:

...
echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::class, [
    'captchaAction' => "/site/captcha",
    'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]);
...

If you want to use only expressions with a subtraction operation e.g., then you need to set the operations property accordingly in the description of the action in the controller:

public function actions()
{
    return [
        ...
        'captcha' => [
            'class' => \app\components\actions\MathCaptchaAction::class,
            'fixedVerifyCode' => YII_ENV_TEST ? '399' : null,
            'minLength' => 0,
            'maxLength' => 1000,
            'operations' => ['-'],
        ],
        ...
    ];
}

Expressions with multiplication

If you want to use also expressions with a multiplication operation, then you need to set the operations property accordingly in the description of the action in the controller:

public function actions()
{
    return [
        ...
        'captcha' => [
            'class' => \app\components\actions\MathCaptchaAction::class,
            'fixedVerifyCode' => YII_ENV_TEST ? '399' : null,
            'minLength' => 0,
            'maxLength' => 1000,
            'operations' => ['+', '-', '*'],
        ],
        ...
    ];
}

Three kinds of expressions can be generated:

  1. Expression with multiplication.
    Screenshot
  2. Expression with multiplication and addition.
    Screenshot
  3. Expression with multiplication and subtraction.
    Screenshot

Author

long399, e-mail: long399@mail.ru

统计信息

  • 总下载量: 2.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-16