Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
Y

yii2-settings

> 编程语言
Open source

Persistent settings in Yii2

100 stars0 likes1 views
WebsiteGitHub

About

Persistent settings in Yii2

Yii2 Settings Extension

Persistent, application-wide settings for Yii2.

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

Installation

The preferred way to install this extension is through composer.

Either run

bash
php composer.phar require --prefer-dist yii2mod/yii2-settings "*"

or add

"yii2mod/yii2-settings": "*"

to the require section of your composer.json.

Configuration

Database Migrations

Before usage this extension, we'll also need to prepare the database.

bash
php yii migrate --migrationPath=@vendor/yii2mod/yii2-settings/migrations

Module Setup

To access the module, you need to configure the modules array in your application configuration:

php
'modules' => [
    'settings' => [
        'class' => 'yii2mod\settings\Module',
    ],
],

You can then access settings management section through the following URL:

http://localhost/path/to/index.php?r=settings

or if you have enabled pretty URLs, you may use the following URL:

http://localhost/path/to/index.php/settings

Component Setup

To use the Setting Component, you need to configure the components array in your application configuration:

php
'components' => [
    'settings' => [
        'class' => 'yii2mod\settings\components\Settings',
    ],
],

Usage:

…

Manage custom settings

You can use your own form model to manage custom settings for your web application via SettingsAction. To use the SettingsAction class you need to follow the following steps:

  1. Create your own model, for example:
php
 Yii::t('app', 'Application Name'),
            'adminEmail' => Yii::t('app', 'Admin Email'),
        ];
    }
}
  1. Create view file, named settings.php with the following content:
php
title = Yii::t('app', 'Manage Application Settings');
?>

field($model, 'appName'); ?>

field($model, 'adminEmail'); ?>

 'btn btn-success']) ?>
  1. Add settings action to your controller class as follows:
php
 [
                'class' => \yii2mod\settings\actions\SettingsAction::class,
                // also you can use events as follows:
                'on beforeSave' => function ($event) {
                    // your custom code
                },
                'on afterSave' => function ($event) {
                    // your custom code
                },
                'modelClass' => \app\models\forms\ConfigurationForm::class,
            ],
        ];
    }
}

Now you can access to the settings page by the following URL: http://localhost/path/to/index.php?r=site/manage-settings/

Internationalization

All text and messages introduced in this extension are translatable under category 'yii2mod.settings'. You may use translations provided within this extension, using following application configuration:

php
return [
    'components' => [
        'i18n' => [
            'translations' => [
                'yii2mod.settings' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@yii2mod/settings/messages',
                ],
                // ...
            ],
        ],
        // ...
    ],
    // ...
];

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPyii2yii2-extensionyii2-settingsyii2-settings-module

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言