johnitvn/yii2-settings

支持GUI管理器的数据库模块的Yii2设置

安装次数: 5,296

依赖者: 0

建议者: 0

安全性: 0

星标: 24

关注者: 5

分支: 17

开放性问题: 3

类型:yii2-extension

1.0.5 2016-02-01 13:32 UTC

This package is auto-updated.

Last update: 2024-09-19 10:38:42 UTC


README

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads

支持GUI管理器的数据库模块的Yii2设置

yii2-settings

安装

安装此扩展的首选方式是通过 composer

运行以下命令:

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

或者将以下内容添加到你的 composer.json 文件的 require 部分:

"johnitvn/yii2-settings": "*"

用法

####将设置添加到组件配置

'components' => [        
    'settings'=>[
        'class'=>'johnitvn\settings\Settings'
    ],
],

####让我们看看这个代码片段如何使用

$settings = Yii::$app->settings;

$value = $settings->get('section,'key');

$settings->set('section','key', 'value', 'integer');

$settings->delete('section,'key');

$settings->deleteAll('section,'key');

$settings->clearCache(); // automatic call when use set()

####看这一行

$settings->set($section,$key,$value,$type);

你可以使用 $section 来分配设置,例如系统、用户等。$type 将用于获取设置。此扩展使用了 settype 来设置获取设置时的类型

####如果你想使用GUI管理设置,则将设置添加到模块配置

'modules' => [
    'settings' =>  [
        'class'=>'johnitvn\settings\Module',
    ]       
]

然后访问 localhost/index.php?r=settings/manager/index.php