PHPackages                             vsevolod-ryzhov/yii2-code-validation - 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. vsevolod-ryzhov/yii2-code-validation

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

vsevolod-ryzhov/yii2-code-validation
====================================

Validate form change via secret code (SMS and etc)

v0.2(5y ago)00MITPHPPHP &gt;=7.1CI failing

Since May 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/vsevolod-ryzhov/yii2-code-validation)[ Packagist](https://packagist.org/packages/vsevolod-ryzhov/yii2-code-validation)[ RSS](/packages/vsevolod-ryzhov-yii2-code-validation/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (3)Used By (0)

Code validation service for Yii2 models
=======================================

[](#code-validation-service-for-yii2-models)

Validate model change via code delivered by external service (SMS, email &amp; etc)

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

[](#installation)

Via Composer

```
composer require vsevolod-ryzhov/yii2-code-validation

```

Usage
-----

[](#usage)

Inject service in your Controller:

```
private $service;

public function __construct($id, $module, \vsevolodryzhov\yii2CodeValidation\Service $service, $config = [])
{
    parent::__construct($id, $module, $config);
    $this->service = $service;
}
```

create action with some form (Model or ActiveRecord):

```
public function actionChangeRequest()
{
    $form = new Form();

    if ($form->load(Yii::$app->request->post()) && $form->validate()) {
        // if form submitted and validated use "set" function to store form and get generated code
        $code = $this->service->set($form);
        // send $code here and then redirect to verify action
        return $this->redirect('/verify');
    }

    return $this->render('change', ['form' => $form]);
}
```

create verify action:

```
public function actionVerify()
{
    if (!$this->service->exists()) {
        // if nothing to verify - throw new Exception, redirect or do something else
    }

    // create CodeValidationForm (included in this package) with stored code and new instance of same form, created in previews action
    $form = new \vsevolodryzhov\yii2CodeValidation\CodeValidationForm($this->service->getCode(), new Form($this->service->getData()));

    if ($form->load(Yii::$app->request->post()) && $form->validate()) {
        // clear all data on success
        $this->service->clear();
        // refresh or redirect to success page
        return $this->refresh();
    }

    return $this->render('verify', ['form' => $form]);
}
```

also, you can create additional action for updating existing code

```
public function actionUpdate()
{
    $response = $this->service->renewCode();
}
```

`renewCode` action returns `\vsevolodryzhov\yii2CodeValidation\Response` object with some useful information:

- `$response->getDone()` returns true if code was updated
- `$response->getWait()` returns number of seconds time until the next possible update time
- `$response->getCode()` returns new code (if generated) or null

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

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

Total

2

Last Release

2172d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3246627?v=4)[Vsevolod Ryzhov](/maintainers/vsevolod-ryzhov)[@vsevolod-ryzhov](https://github.com/vsevolod-ryzhov)

---

Top Contributors

[![vsevolod-ryzhov](https://avatars.githubusercontent.com/u/3246627?v=4)](https://github.com/vsevolod-ryzhov "vsevolod-ryzhov (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vsevolod-ryzhov-yii2-code-validation/health.svg)

```
[![Health](https://phpackages.com/badges/vsevolod-ryzhov-yii2-code-validation/health.svg)](https://phpackages.com/packages/vsevolod-ryzhov-yii2-code-validation)
```

###  Alternatives

[borales/yii2-phone-input

Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget

1341.6M6](/packages/borales-yii2-phone-input)[codeonyii/yii2-at-least-validator

Validates at least one (or more) attributes.

28253.5k1](/packages/codeonyii-yii2-at-least-validator)[arogachev/yii2-many-to-many

Many-to-many ActiveRecord relation for Yii 2 framework

3541.2k4](/packages/arogachev-yii2-many-to-many)[yiibr/yii2-br-validator

Provide validations and features for brazilian localization

14103.2k4](/packages/yiibr-yii2-br-validator)[yii2mod/yii2-validators

Collection of useful validators for Yii Framework 2.0

1816.8k](/packages/yii2mod-yii2-validators)

PHPackages © 2026

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