Giter Site home page Giter Site logo

yii2-captcha's Introduction

yii2 captcha

yii2 验证码功能,能够处理文字、数字及外文字符集功能。

yii2 captcha with Ability to recognize Arabic and Persian numbers.

screenshot

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"daimakuai/yii2-captcha": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply modify your controler, add or change methode actions():

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

在视图里增加 In view

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

或增加
or add
<?php echo Captcha::widget(['name'=>'captchaimg','captchaAction'=>'captcha']); ?>

在后台Action获取验证码并验证,添加如下代码
Where background checks are needed add.

<?php

$check = $this->createAction('captcha')->validate($captchCode, false);
if($check){
	//验证码正确
}else{
	//验证码错误
}
?>

yii2-captcha's People

Contributors

daimakuai avatar

Stargazers

Joey Wong avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.