PHPackages                             daimakuai/yii2-captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. daimakuai/yii2-captcha

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

daimakuai/yii2-captcha
======================

yii2 captcha

v1.2(8y ago)118BSD-4-ClausePHP

Since Jan 27Pushed 8y agoCompare

[ Source](https://github.com/daimakuai/yii2-captcha)[ Packagist](https://packagist.org/packages/daimakuai/yii2-captcha)[ RSS](/packages/daimakuai-yii2-captcha/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

yii2 captcha
============

[](#yii2-captcha)

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

yii2 captcha with Ability to recognize Arabic and Persian numbers.

[![screenshot](https://raw.githubusercontent.com/daimakuai/yii2-captcha/master/screen.jpg)](https://raw.githubusercontent.com/daimakuai/yii2-captcha/master/screen.jpg)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

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
-----

[](#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;
