PHPackages                             novikas/yii2-numerator - 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. novikas/yii2-numerator

ActiveYii2-extension

novikas/yii2-numerator
======================

Experemental extension that allows you to numerate whatever in your app

02PHP

Since Feb 16Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Yii 2 Numerator extension
=========================

[](#yii-2-numerator-extension)

rapidly creating small projects.

The template contains the basic features including user login/logout and a contact page. It includes all commonly used configurations that would allow you to focus on adding new features to your application.

[![Latest Stable Version](https://camo.githubusercontent.com/1110e9d4bed6fcb6a0d6c66c27d9da80543782429b09edfa5741f9c665291eac/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f796969322d6170702d62617369632f762f737461626c652e706e67)](https://packagist.org/packages/novikas/yii2-numerator)

REQUIREMENTS
------------

[](#requirements)

The minimum requirement by this extension that your Web server supports PHP 5.4.0.

INSTALLATION
------------

[](#installation)

### Install via Composer

[](#install-via-composer)

If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).

You can then install this extension using the following command:

```
php composer.phar require novikas/yii2-numerator: "@dev"

```

### Database

[](#database)

First of all you need to execute migrations that is located in extensions directory:

```
yii mirate --migrationsPath = @novikas/numerator/migrations
```

To create new simple numerator template, you need to call Numerator::createNumerator($config) just once. Argument config is an array:

```
Numerator::createNumerator([
  'name' => 'doc_numerator1',
  'model_class' => 'common\models\Doc',
  'field' => 'number',
  'type_field' => 'type',
  'type_value' => 1,
  'mask' => '{УК-}999',
  'init_val' => 55
]);
```

If your models differs from each other by more than on field (property), you can use the following template:

```
Numerator::createNumerator([
  'name' => 'doc_numerator2',
  'model_class' => 'common\models\Doc',
  'field' => 'number',
  'type_field' => 'type1&type2',
  'type_value' => "1&2",
  'mask' => '{UK-}999',
  'init_val' => 2
]);
```

So, according this template numerator will numerate your models by following condition

```
WHERE type1 = 1 AND type2 = 2
```

**NOTE**Note that values of the properties Numerator::type\_value and Numerator::type\_field must corresponds.

If your models differs in properties of their relations, you can use the following template:

```
Numerator::createNumerator([
  'name' => 'doc_numerator2',
  'model_class' => 'common\models\Doc',
  'field' => 'number',
  'type_field' => 'doc.type1&store.type2',
  'type_value' => "1&2",
  'mask' => '{UK-}999',
  'init_val' => 2,
  'join_table' => 'store',
  'join_on_condition' => 'doc.FK_store=store.id'
]);
```

**NOTE**Note that you need to set properties Numerator::join\_table and Numerator::join\_on\_condition. Also it's recommended to add table prefix in property type\_field to avoid ambiguity.

### Fields description

[](#fields-description)

- name - unique template name.
- model\_class - Class of ActiveRecord model that need to be numerated.
- field - field of model\_class instance that contains number.
- type\_field - field of model\_class instance that contains model type.
- type\_value - I suppose that is clear
- mask - numerator's mask
- init\_val - initial value for number. Numeration will be proceed after this value.

### Mask description

[](#mask-description)

- {} - text between curly brackets will display as it is.
- 9 - means that this position is reserved as a number.
- y - will be replaced with current year.
- m - will be replaced with current month.
- q - will be replaced with current quarter. **NOTE**

- Current version of code allows only one block with curly brackets, only one sequence of symbol 9 (9999) and this sequence must be placed last.

### Usage

[](#usage)

After you created all templates for your models, you can use Numerator as the following code:

```
$numerator = Numerator::getNumerator($templateName);
$doc->number = $numerator->nextNumber();
```

This code could be place in rules of models as a default value for number property for example.

###  Health Score

19

—

LowBetter than 12% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![novikas](https://avatars.githubusercontent.com/u/10496563?v=4)](https://github.com/novikas "novikas (11 commits)")

### Embed Badge

![Health badge](/badges/novikas-yii2-numerator/health.svg)

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

PHPackages © 2026

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