Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yiithings/yii2-setting

Dynamically construct, validate, and display application setting variables in Yii2 application
https://github.com/yiithings/yii2-setting

settings yii2-extension yii2-framework yii2-settings

Last synced: 10 days ago
JSON representation

Dynamically construct, validate, and display application setting variables in Yii2 application

Awesome Lists containing this project

README

        

Yii2 Setting
============
[![Build Status](https://travis-ci.org/yiithings/yii2-setting.svg)](https://travis-ci.org/yiithings/yii2-setting)
[![Latest Stable Version](https://poser.pugx.org/yiithings/yii2-setting/v/stable.svg)](https://packagist.org/packages/yiithings/yii2-setting)
[![Total Downloads](https://poser.pugx.org/yiithings/yii2-setting/downloads.svg)](https://packagist.org/packages/yiithings/yii2-setting)
[![Latest Unstable Version](https://poser.pugx.org/yiithings/yii2-setting/v/unstable.svg)](https://packagist.org/packages/yiithings/yii2-setting)
[![License](https://poser.pugx.org/yiithings/yii2-setting/license.svg)](https://packagist.org/packages/yiithings/yii2-setting)

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`、, `AdminLTE` 和 `Gentelella Alela!` ,
同时提供了命令行工具、 Gii 生成工具以及设置项迁移工具。

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

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

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

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 :
```php
'components' => [、
'setting' => [
'class' => 'yiithings\setting\Setting',
]
],
'modules' => [
'settings' => [
'class' => 'yiithings\setting\Module',
]
],
```

> 组件 API 参见 [Setting Class](src/Setting.php)

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

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

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

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