PHPackages                             myzero1/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. myzero1/yii2-captcha

ActiveYii2-module[Utility &amp; Helpers](/categories/utility)

myzero1/yii2-captcha
====================

Simple captcha for yii2.Just add the module in config file and use the widget.

2.1.0(2y ago)0144MITPHP

Since Nov 28Pushed 2y agoCompare

[ Source](https://github.com/myzero1/yii2-captcha)[ Packagist](https://packagist.org/packages/myzero1/yii2-captcha)[ RSS](/packages/myzero1-yii2-captcha/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

yii2-captcha
============

[](#yii2-captcha)

Simple captcha for yii2.Just add the module in config file and use the widget.

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

[](#installation)

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

Either run

```
php composer.phar require myzero1/yii2-captcha：1.*

```

or add

```
"myzero1/yii2-captcha": "~1"

```

to the require section of your `composer.json` file.

Setting
-------

[](#setting)

Once the extension is installed, simply modify your application configuration as follows:

```
return [
	// ...
    'bootstrap' => ['captcha',...],
    'modules' => [
        'captcha' => [
            'class' => 'myzero1\captcha\Module',
            // 'maxLen' => 4, //最大显示个数
            // 'minLen' => 4, //最少显示个数
            // 'timeout' => 300, //过期时间，单位为秒
            // 'key' => 'myzero1自研', //用于验证码加密
            // 'source' => '0123456789abcdefghijklmnopqrstuvwxyz', //候选字符，不支持中文的图片渲染，但支持生成中文验证码
            // 'width' => 130,  //宽度
            // 'height' => 32, //高度
            // 'bgColor' => '#dddddd', //背景颜色,六位的rgb
            // 'fontSize' => 24, //字体大小,最大值是 5,这个值对应于 14 像素的字体大小,越大字间距越大
            // 'startLeftTopPoint' => [10,5], //字符起点的左上角坐标
            // 'noiseSpot' => 50, //干扰点数量
            // 'noiseLine' => 3, //干扰线数量
        ],
        // ...
    ],
    // ...
];
```

Usage
-----

[](#usage)

Add upload widget like following:

```

echo \myzero1\captcha\widgets\Captcha::widget([
    'model' => new \myzero1\captcha\models\Captcha(['scenario'=>'js']),
    // 'model' => new \myzero1\captcha\models\Captcha(['scenario'=>'jsPhp']),
    'attribute' => 'verifyCode',
    'imageOptions'=>[
        'alt'=>'点击换图',
        'title'=>'点击换图',
        'style'=>'cursor:pointer'
    ]
]);

```

With ActiveForm

```

echo  $form
// ->field(new \myzero1\captcha\models\Captcha(['scenario'=>'php']),'verifyCode')
->field(new \myzero1\captcha\models\Captcha(['scenario'=>'jsPhp']),'verifyCode')
->widget(
    myzero1\captcha\widgets\Captcha::className(),
    [
        'imageOptions'=>[
            'alt'=>'点击换图',
            'title'=>'点击换图',
            'style'=>'cursor:pointer'
        ]
    ]
)

```

The scenario discretion

- php: Just validate by PHP.
- jsPhp: validate by JS and PHP

You can access Demo through the following URL:

```
http://localhost/path/to/index.php?r=captcha/default/demo

```

or if you have enabled pretty URLs, you may use the following URL:

```
http://localhost/path/to/index.php/captcha/default/demo

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 70.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~571 days

Total

5

Last Release

805d ago

Major Versions

1.0.1 → 2.0.02024-02-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22048203?v=4)[myzero1](/maintainers/myzero1)[@myzero1](https://github.com/myzero1)

---

Top Contributors

[![mywoogle](https://avatars.githubusercontent.com/u/8934318?v=4)](https://github.com/mywoogle "mywoogle (19 commits)")[![myzero1](https://avatars.githubusercontent.com/u/22048203?v=4)](https://github.com/myzero1 "myzero1 (8 commits)")

### Embed Badge

![Health badge](/badges/myzero1-yii2-captcha/health.svg)

```
[![Health](https://phpackages.com/badges/myzero1-yii2-captcha/health.svg)](https://phpackages.com/packages/myzero1-yii2-captcha)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
