exchangecore/yii2-config
Composer 安装命令:
composer require exchangecore/yii2-config
包简介
Configuration components for Yii2
关键字:
README 文档
README
First you must install the extension using composer. To do so simply add it to your application's composer.json like so:
"require": {
"exchangecore/yii2-config": "dev-master",
},
To set up a configuration repository you should use something similar to below in your yii configuration file. The
db and table properties are optional. You MUST name the component 'config' for the DbRepository to work.
'components' => [
'config' => [
'class' => 'exchangecore\config\components\DbRepository',
// 'db' => 'db',
// 'table' => 'Config'
]
],
'modules' => [
'config' => ['class' => 'exchangecore\config\Module'],
],
Before you can leverage the DbRepository you must install the table. To do so run the following from the command line:
php yii migrate --migrationPath="@exchangecore/config/migrations"
Now you can start saving and getting values from your configuration component like so:
//to save a configuration value
\Yii::$app->config->save('namespace::group.item.item1', $value);
\Yii::$app->config->save('namespace::group.item.item2', $value2);
//to retrieve a configuration value
\Yii::$app->config->get('namespace::group.item.item1'); //returns $value
\Yii::$app->config->get('namespace::group.item'); //returns array('item1' => $value, 'item2' => $value2)
Thanks To
Most of what you'll find in this extension/module is a version of what is used by Concrete5 and Illuminate.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-25