tpoxa/yii2-settings

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

安装: 9

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 17

类型:yii2-extension

1.0.5 2016-02-01 13:32 UTC

This package is not auto-updated.

Last update: 2024-09-20 19:04:25 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