scabbiafw/scabbia2-config
最新稳定版本:v0.1.1
Composer 安装命令:
composer require scabbiafw/scabbia2-config
包简介
Scabbia2 Config Component
README 文档
README
This component is a configuration compiler which supports binding multiple configuration files.
Usage
Merging multiple configurations
use Scabbia\Config\ConfigCollection; $confs = new ConfigCollection(); // add a yaml-parsed configuration $yaml = new \Scabbia\Yaml\Parser(); $confs->add($yaml->parse(file_get_contents('common.yml'))); // ...and/or add a json file $confs->add(json_decode(file_get_contents('production.json'))); // ...and/or add a configuration value manually $confs->add([ 'env' => 'development' ]); // output the result $config = $confs->save(); print_r($config);
Overriding an existing configuration item
use Scabbia\Config\ConfigCollection; $confs = new ConfigCollection(); $confs->add([ 'env' => 'production' ]); // in second config you can override a value with 'important' flag $confs->add([ 'env|important' => 'development' ]); // output the result $config = $confs->save(); echo $config['env'];
Constructing a list in separate configurations
use Scabbia\Config\ConfigCollection; $confs = new ConfigCollection(); $confs->add([ 'items|list' => [ 'first', 'second' ] ]); // in second config you can override a value with 'important' flag $confs->add([ 'items|list' => [ 'third' ] ]); // output the result $config = $confs->save(); print_r($config['items']);
Flatten configuration value keys
use Scabbia\Config\ConfigCollection; $confs = new ConfigCollection(); $confs->add([ 'database|flat' => [ 'mongo' => [ 'username' => 'scabbia2', 'password' => 'testing' ] ] ]); // output the result $config = $confs->save(); echo $config['database/mongo/username']; echo $config['database/mongo/password'];
Links
Contributing
It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome. All contributions should be filed on the eserozvataf/scabbia2-config repository.
统计信息
- 总下载量: 98
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2015-09-16