yiithings/yii2-setting

Site setting extension

Installs: 90

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2018-01-13 04:31 UTC

This package is not auto-updated.

Last update: 2024-04-14 02:34:52 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

It helps you to dynamically construct, validate, and display setting variables in the Yii2 framework.

Supports Bootstrap(default), AdminLTE and Gentelella Alela!.

What's This

Yii2 Setting 是一个通用型的 设置 拓展,可以为 Yii2 应用提供开箱即用的定制、操作和显示配置项的功能。它可以帮助你动态的构造配置项, 并将设置的验证规则,数据处理方式等拓展信息保存在数据库。它的配置页面预置支持 Bootstrap、, AdminLTEGentelella Alela! , 同时提供了命令行工具、 Gii 生成工具以及设置项迁移工具。

一个理想的使用情景是,开发者在本地开发环境使用命令行或者页面生成工具创建需要的设置项,配置设置项规则, 然后使用迁移工具 ( Migration ) 将设置迁移至指定的线上环境。

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiithings/yii2-setting "*"

or add

"yiithings/yii2-setting": "*"

to the require section of your composer.json file.

Usage

拓展分为包含 yiithings\setting\Setting 组件和 yiithings\setting\Module 模块,yiithings\setting\Setting 组件是必须的, 是对配置项进行 CRUD 的统一入口。yiithings\setting\Module 模块是可选的,提供了 Web 端配置页面与控制台命令行,并会设置一些所需属性。 通常,我们将组件 ID 设置为 setting,将模块 ID 设置为 settings

Once the extension is installed, simply use it in your code by :

'components' => [、
    'setting' => [
        'class' => 'yiithings\setting\Setting',
    ]
],
'modules' => [
    'settings' => [
        'class' => 'yiithings\setting\Module',
    ]
],

组件 API 参见 Setting Class

模块页面对 AdminLTEGentelella Alela! 两种主题提供了主题化定制(默认为Bootstrap)。如果你的应用使用了这两种主题中的一个, 可以通过配置 theme 属性来设置主题。

'modules' => [
    'settings' => [
        'class' => 'yiithings\setting\Module',
        'theme' => 'gentelella',
    ]
],

模块使用了 I18N 组件并且预置了一些语言的翻译。如果预置翻译没有你所需要的语言或不能满足要求,可自行添加翻译。拓展使用了 yiithings/setting 作为消息分类名。

[
    'i18n' => [
        'translations' => [
            'yiithings/setting' => [
               'class'          => 'yii\i18n\PhpMessageSource',
               'sourceLanguage' => 'en',
               'basePath'       => 'YOU_PATH',
               'fileMap'        => [
                   'yiithings/setting' => 'YOU_PATH',
               ],
           ]
        ]
    ]
]