PHPackages                             bupy7/yii2-config - 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. [Database &amp; ORM](/categories/database)
4. /
5. bupy7/yii2-config

AbandonedArchivedYii2-extension[Database &amp; ORM](/categories/database)

bupy7/yii2-config
=================

This is module allow storing configuration parameters of application to database and management they dynamically from admin panel.

1.1.0(9y ago)172.6k9BSD-3-ClausePHP

Since Aug 28Pushed 9y ago2 watchersCompare

[ Source](https://github.com/bupy7/yii2-config)[ Packagist](https://packagist.org/packages/bupy7/yii2-config)[ RSS](/packages/bupy7-yii2-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

yii2-config
===========

[](#yii2-config)

This is module allow storing configuration parameters of application to database and management they dynamically from admin panel.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist bupy7/yii2-config "*"

```

or add

```
"bupy7/yii2-config": "*"

```

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

Usage
-----

[](#usage)

Added to main application config:

```
'bootstrap' => [
    ...

    'config',

    ...
],
'modules' => [
    'config' => [
        'class' => 'bupy7\config\Module',
        'enableCaching' => !YII_DEBUG,
        'as access' => [
            'class' => AccessControl::className(),
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['admin'],
                ],
            ],
        ],
    ],
],
'components' => [
    'configManager' => [
        'class' => 'bupy7\config\components\ConfigManager',
    ],
],
```

Run migration:

```
./yii migrate/up --migrationPath=@bupy7/config/migrations

```

Install demo parameters:

```
./yii config/init

```

Config manager allowed by URL:

```
config/default/index

```

### Adding config parameters

[](#adding-config-parameters)

All config parameters **necessarily** must contain following options:

- `module` *(string)* - Name of module parameter where it will be use (app, shop, cart, blog, news and etc.).
- `name` *(string)* - Name of parameter (mainPageTitle, adminEmail and etc.).

> Module name and name must be unique.

- `label` *(string)* - Label of parameter. It must be translation message. More info to `Yii::t()`.
- `type` *(integer)* - Type of field (`bupy7\config\Module::TYPE_INPUT`, `bupy7\config\Module::TYPE_TEXT` and etc). Allowed type field you can see to `bupy7\config\Module`.
- `rules` *(array)* - Rules of field. All rules must be specified without field name. Example:

```
'rules' => [
    ['required'],
    ['string', 'max' => 255],
],
```

More info to `bupy7\config\models\Config::afterFind()`.

Additional options:

- `language` *(string)* - Language for which this config parameter will be uses ('ru', 'en' and etc). If language is `bupy7\config\Module::LANGUAGE_ALL` or not set, then this parameter will be uses for all languages. More info `yii\console\Application::$language|yii\web\Application::$language`.
- `value` *(string)* - Value of config parameter. By default empty.
- `options` *(array)* - Options depend of field type. More info to `bupy7\config\widgets\ActiveForm::field()`. Example for `textInput` type:

```
'options' => [
    ['maxlength' => true]
],
```

- `hint` *(string)* - Hint of field. It must be translation message. More info to `Yii::t()`.

Example configuration parameters:

```
use bupy7\config\Module as ConfigModule;

...
'modules' => [

    ...

    'config' => [
        'class' => 'bupy7\config\Module',
        'enableCaching' => !YII_DEBUG,
        'as access' => [
            'class' => AccessControl::className(),
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['admin'],
                ],
            ],
        ],
        'params' => [
            [
                'module' => 'app',
                'name' => 'backendSitename',
                'label' => 'PARAM_BACKEND_SITENAME',
                'value' => 'Backend',
                'type' => ConfigModule::TYPE_INPUT,
                'language' => 'en',
                'rules' => [
                    ['required'],
                    ['string', 'max' => 255],
                ],
                'options' => [
                    ['maxlength' => true]
                ],
            ],
            [
                'module' => 'app',
                'name' => 'frontendSitename',
                'label' => 'PARAM_FRONTEND_SITENAME',
                'value' => 'Frontend',
                'type' => ConfigModule::TYPE_INPUT,
                'language' => 'en',
                'rules' => [
                    ['required'],
                    ['string', 'max' => 255],
                ],
                'options' => [
                    ['maxlength' => true]
                ],
            ],
            [
                'module' => 'app',
                'name' => 'displaySitename',
                'label' => 'PARAM_DISPLAY_SITENAME',
                'value' => '0',
                'type' => ConfigModule::TYPE_YES_NO,
                'language' => ConfigModule::LANGUAGE_ALL,
                'rules' => [
                    ['boolean'],
                ],
                'hint' => 'HINT_PARAM_DISPLAY_SITENAME',
            ],
            [
                'module' => 'app',
                'name' => 'supportEmail',
                'label' => 'PARAM_SUPPORT_EMAIL',
                'value' => 'support@support.com',
                'type' => ConfigModule::TYPE_INPUT,
                'language' => ConfigModule::LANGUAGE_ALL,
                'rules' => [
                    ['required'],
                    ['email'],
                ],
            ],
            [
                'module' => 'app',
                'name' => 'supportNameEmail',
                'label' => 'PARAM_SUPPORT_NAME_EMAIL',
                'value' => 'Support of site',
                'type' => ConfigModule::TYPE_INPUT,
                'language' => 'en',
                'rules' => [
                    ['required'],
                    ['string', 'max' => 255],
                ],
                'options' => [
                    ['maxlength' => true]
                ],
            ],
        ],
    ],

    ...

],
```

After added configuration parameters run rescan:

```
./yii config/rescan

```

Result:

[![Screenshot](screenshot.png)](screenshot.png)

### Get value of config parameter

[](#get-value-of-config-parameter)

```
Yii::$app->configManager->get('exampleModuleName', 'exampleParameterName');
```

> If parameter not found, then will be throw exception.

### Set value of config parameter

[](#set-value-of-config-parameter)

```
Yii::$app->configManager->set('exampleModuleName', 'exampleParameterName', 'exampleParameterValue');
```

> If parameter not found, then will be throw exception.

### Console commands

[](#console-commands)

> By default command name equals module name (module name - `config` and command name - `config`).

Initialization the configuration parameters of application with deleting old parameters:

```
./yii config/init

```

Adding new and deleting not exists config parameters of application:

```
./yii config/rescan

```

> After successfully adding/deleting parameters cache will be cleared.

\##License

yii2-config is released under the BSD 3-Clause License.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% 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 ~101 days

Recently: every ~126 days

Total

6

Last Release

3401d ago

### Community

Maintainers

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

---

Top Contributors

[![bupy7](https://avatars.githubusercontent.com/u/5145037?v=4)](https://github.com/bupy7 "bupy7 (52 commits)")[![filsh](https://avatars.githubusercontent.com/u/6173680?v=4)](https://github.com/filsh "filsh (2 commits)")

---

Tags

configyii2extensionmodule

### Embed Badge

![Health badge](/badges/bupy7-yii2-config/health.svg)

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

###  Alternatives

[johnitvn/yii2-ajaxcrud

Gii CRUD template for Single Page Ajax Administration for yii2

97209.6k16](/packages/johnitvn-yii2-ajaxcrud)[dmstr/yii2-db

Database extensions

19618.8k6](/packages/dmstr-yii2-db)

PHPackages © 2026

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