# GACaptcha **Repository Path**: zhyun/GACaptcha ## Basic Information - **Project Name**: GACaptcha - **Description**: GACaptcha is a captcha component for Yii2. - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-03-14 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: captcha **Tags**: None ## README # GACaptcha(best,easy) # ## Installation ## `composer require ga/captcha dev-master` ## 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. ```PHP 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. ```PHP 'captcha', 'template' => '  {input}{image}', 'options' => ['id' => 'captcha'], ]);?> ``` **NOTE:** If you change the url route, and you need to set the `captchaAction` property. ```PHP 'controller/action' ]);?> ``` 3.Config your method need to validate the verification code. ```PHP 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.