PHPackages                             long399/yii2-math-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. long399/yii2-math-captcha

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

long399/yii2-math-captcha
=========================

yii2 MathCaptchaAction

0.1.2(4y ago)13.1k↓48%MITPHP

Since Aug 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ProkopenkoRoman/yii2-math-captcha)[ Packagist](https://packagist.org/packages/long399/yii2-math-captcha)[ Docs](https://github.com/ProkopenkoRoman/yii2-math-captcha)[ RSS](/packages/long399-yii2-math-captcha/feed)WikiDiscussions main Synced 1mo ago

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

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

[](#yii2-math-captcha)

[![Total Downloads](https://camo.githubusercontent.com/204d6977f8b8906e9464034a3d624d652aebcab9a3a74121b3442e1acb5d0cad/687474703a2f2f706f7365722e707567782e6f72672f6c6f6e673339392f796969322d6d6174682d636170746368612f646f776e6c6f616473)](https://packagist.org/packages/long399/yii2-math-captcha)[![License](https://camo.githubusercontent.com/a06c19e1c48e2ce29ac5f8e2c8f4c83f7d847a30712137546c300d3ed0b3537d/687474703a2f2f706f7365722e707567782e6f72672f6c6f6e673339392f796969322d6d6174682d636170746368612f6c6963656e7365)](https://packagist.org/packages/long399/yii2-math-captcha)

MathCaptchaAction for Yii Framework 2.0

[![Screenshot](https://camo.githubusercontent.com/8eab330cb450a06714a6c9ac34c568302492027fb9d1b1410eab861b871a6aa0/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383426643d31363239303838393839 "Screenshot")](https://camo.githubusercontent.com/8eab330cb450a06714a6c9ac34c568302492027fb9d1b1410eab861b871a6aa0/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383426643d31363239303838393839)

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

[](#installation)

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

```
 composer require --prefer-dist long399/yii2-math-captcha

```

or add

```
"long399/yii2-math-captcha": "~0.1"
```

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

Available operations
--------------------

[](#available-operations)

1. Addition.
2. Subtraction.
3. Multiplication.

Default addition or subtraction operation will be used randomly.

Usage
-----

[](#usage)

controller:

```
public function actions()
{
    return [
        ...
        'captcha' => [
            'class' => \long399\captcha\MathCaptchaAction::class,
            'fixedVerifyCode' => YII_ENV_TEST ? '399' : null,
            'minLength' => 0,
            'maxLength' => 1000,
        ],
        ...
    ];
}
```

model:

```
class MyModel extends \yii\db\ActiveRecord
{
    public $captcha;
    ...
    public function rules()
    {
        return [
            ...
            ['captcha', 'captcha', 'captchaAction' => '/site/captcha'],
            ...
        ];
    }
    ...
}
```

view:

```
...
echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::class, [
    'captchaAction' => "/site/captcha",
    'template' => '{image}{input}',
]);
...
```

If you want to use only expressions with a subtraction operation e.g., then you need to set the **operations** property accordingly in the description of the action in the controller:

```
public function actions()
{
    return [
        ...
        'captcha' => [
            'class' => \app\components\actions\MathCaptchaAction::class,
            'fixedVerifyCode' => YII_ENV_TEST ? '399' : null,
            'minLength' => 0,
            'maxLength' => 1000,
            'operations' => ['-'],
        ],
        ...
    ];
}
```

Expressions with multiplication
-------------------------------

[](#expressions-with-multiplication)

If you want to use also expressions with a multiplication operation, then you need to set the **operations** property accordingly in the description of the action in the controller:

```
public function actions()
{
    return [
        ...
        'captcha' => [
            'class' => \app\components\actions\MathCaptchaAction::class,
            'fixedVerifyCode' => YII_ENV_TEST ? '399' : null,
            'minLength' => 0,
            'maxLength' => 1000,
            'operations' => ['+', '-', '*'],
        ],
        ...
    ];
}
```

Three kinds of expressions can be generated:

1. Expression with multiplication.
    [![Screenshot](https://camo.githubusercontent.com/95e0f0d970e6d8a8b8c63666f152c6f23302201ef51fe4f959536091b2a57f31/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383526643d31363239313732343331 "Expression with multiplication")](https://camo.githubusercontent.com/95e0f0d970e6d8a8b8c63666f152c6f23302201ef51fe4f959536091b2a57f31/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383526643d31363239313732343331)
2. Expression with multiplication and addition.
    [![Screenshot](https://camo.githubusercontent.com/1ada036488c5ecc9652b271b177e716a080cd8b71c50122dbe868e63dd445f6c/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383626643d31363239313732343331 "Expression with multiplication and addition")](https://camo.githubusercontent.com/1ada036488c5ecc9652b271b177e716a080cd8b71c50122dbe868e63dd445f6c/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383626643d31363239313732343331)
3. Expression with multiplication and subtraction.
    [![Screenshot](https://camo.githubusercontent.com/35533c46a6222079408aa1f4a630834126614f32bb95c657efd48895431c06b7/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383726643d31363239313732343331 "Expression with multiplication and subtraction")](https://camo.githubusercontent.com/35533c46a6222079408aa1f4a630834126614f32bb95c657efd48895431c06b7/68747470733a2f2f7777772e6379626572666f72756d2e72752f626c6f675f6174746163686d656e742e7068703f6174746163686d656e7469643d3730383726643d31363239313732343331)

Author
------

[](#author)

[long399](https://github.com/ProkopenkoRoman/), e-mail:

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~261 days

Total

2

Last Release

1475d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3d7f87a118670896f6fa52dffc54e8ff97d2c157be9c0389ebe2f1d704e6e79?d=identicon)[ProkopenkoRoman](/maintainers/ProkopenkoRoman)

---

Top Contributors

[![ProkopenkoRoman](https://avatars.githubusercontent.com/u/17271576?v=4)](https://github.com/ProkopenkoRoman "ProkopenkoRoman (16 commits)")

---

Tags

captchayii2extensionyii2-math-captcha

### Embed Badge

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

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

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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