PHPackages                             sakhnovkrg/yii2-settings - 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. sakhnovkrg/yii2-settings

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

sakhnovkrg/yii2-settings
========================

Yii2 settings module

084↓100%PHP

Since Feb 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Sakhnovkrg/Yii2-Settings)[ Packagist](https://packagist.org/packages/sakhnovkrg/yii2-settings)[ RSS](/packages/sakhnovkrg-yii2-settings/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2-Settings
=============

[](#yii2-settings)

[![Total Downloads](https://camo.githubusercontent.com/17cc25d4e984b9e9193beec222f5f656e03160f40ceeb4d06cc7ca2c8d9c39c9/68747470733a2f2f706f7365722e707567782e6f72672f73616b686e6f766b72672f796969322d73657474696e67732f646f776e6c6f6164732e737667)](https://packagist.org/packages/sakhnovkrg/yii2-settings)[![License](https://camo.githubusercontent.com/822922f1872e13b4b679390e1d4cbe7b54ef410f363dc81623de739451a79f25/68747470733a2f2f706f7365722e707567782e6f72672f73616b686e6f766b72672f796969322d73657474696e67732f6c6963656e73652e737667)](https://packagist.org/packages/sakhnovkrg/yii2-settings)

⚙️ Yii2 Settings Module

[![showcase](https://raw.githubusercontent.com/sakhnovkrg/yii2-settings/master/docs/licecap.gif)](https://raw.githubusercontent.com/sakhnovkrg/yii2-settings/master/docs/licecap.gif)

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

[](#installation)

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

Either run

```
php composer require --prefer-dist sakhnovkrg/yii2-settings "@dev"
```

or add

```
"sakhnovkrg/yii2-settings": "@dev"
```

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

Configuration
-------------

[](#configuration)

Configure console application

```
'controllerMap' => [
    'migrate' => [
        'class' => \yii\console\controllers\MigrateController::class,
        'migrationPath' => [
            '@app/migrations',
            '@settings/migrations',
        ],
    ],
]
```

```
php yii migrate
```

or just apply

```
php yii migrate/up --migrationPath=@settings/migrations
```

Module config example

```
// /admin/settings/default/index

'modules' => [
    'admin' => [
        'class' => 'app\modules\admin\Module',
        'layout' => '@admin/views/layouts/main.php',
        'as access' => [
            'class' => 'yii\filters\AccessControl',
            'except' => ['default/login'],
            'rules' => [
                [
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ]
        ],
        'modules' => [
            'settings' => [
                'class' => \sakhnovkrg\yii2\settings\Module::class,
            ],
        ],
    ],
],
```

Components

```
'components' => [
    'settings' => [
        'class' => \sakhnovkrg\yii2\settings\components\Settings::class,
        // optional
        'modelClass' => \sakhnovkrg\yii2\settings\models\Setting::class,
        'enableFlashMessages' => true,
        'cache' => 'cache',
        'cacheKey' => 'yii2-settings',
        'activeFormClass' => 'yii\\bootstrap5\\ActiveForm',
    ],
    'i18n' => [
        'translations' => [
            'yii2-settings' => [
                'class' => 'yii\i18n\PhpMessageSource',
                'basePath' => '@settings/messages',
            ],
        ],
    ],
],
```

Usage
-----

[](#usage)

Add settings example

```
