2017 © Pedro Peláez
 

library captcha

yii2-captcha

image

ga/captcha

yii2-captcha

  • Friday, January 20, 2017
  • by liuzexin
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

GACaptcha(best,easy)

Installation

composer require ga/captcha dev-master, (*1)

Usage

1.Set up following code in actions method of SiteController.(Default) You can also change the "url" route what you want, but you should change the captchaAction property for CaptchaWidget in the next step., (*2)

Class SiteController extend yii\web\Controller
public function actions()
    {
        return [
            'captcha'=>[
                'class' => 'ga\captcha\CaptchaAction',
            ]
        ];
    }

2.Create Widget in the view file, and it's support the active mode., (*3)


= Html::beginForm('site/test', 'post')?>
= CaptchaWidget::widget([
    'name' => 'captcha',
    'template' => '  {input}{image}',
    'options' => ['id' => 'captcha'],
]);?>
= Html::submitButton('Submit')?>
= Html::endForm()?>

NOTE: If you change the url route, and you need to set the captchaAction property., (*4)

= CaptchaWidget::widget([
    ...,
    'captchaAction'=> 'controller/action'
]);?>

3.Config your method need to validate the verification code., (*5)

public function actionTest(){

    $res = Yii::$app->request->post('captcha');
    $ca = new CaptchaValidator();

    if($ca->validate($res)){
        echo "success";
    }else{
        echo "fail";
    }
}

Others

Thanks for the author of HansKendrickV-Regular.ttf to provide the nice free font., (*6)

The Versions

20/01 2017

dev-master

9999999-dev

yii2-captcha

  Sources   Download

null

The Requires

  • bower-asset/jquery 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable

 

by Avatar liuzexin

yii2 captcha ga yii2-captcha