webiny/config
最新稳定版本:v1.6.1
Composer 安装命令:
composer require webiny/config
包简介
Webiny Config Component
README 文档
README
Config component creates ConfigObject instances from config files.
Currently supported formats: INI, JSON, PHP, YAML and custom drivers.
Install the component
The best way to install the component is using Composer.
composer require webiny/config
For additional versions of the package, visit the Packagist page.
Usage
To use Config component you will need a config file.
Example INI:
[properties]
a = "value"
b.name = "name"
b.value = "value"
Here is an example of creating a ConfigObject:
$config = \Webiny\Components\Config\Config::getInstance()->ini('path/to/file.ini');
This will result in $config object containing the following properties:
$config->properties->a = 'value'; $config->properties->b->name = 'name'; $config->properties->b->value = 'value';
If you don't want to use INI sections, or set custom nest delimiter, specify the following arguments:
$config = \Webiny\Components\Config\Config::getInstance()->ini('path/to/file.ini', false, '_');
You can get your config as string in any format using the following methods:
$string = $config->getAsJson(); $string = $config->getAsPhp(); $string = $config->getAsIni($useSections = true, $nestDelimiter = '.'); $string = $config->getAsYaml($indent = 4);
And you can also use custom driver
$driverInstance = new MyCustomDriver(); $string = $config->getAs($driverInstance);
You can also merge one config with another ConfigObject or array:
$config->mergeWith($config2);
Resources
To run unit tests, you need to use the following command:
$ cd path/to/Webiny/Component/Config/
$ composer.phar install
$ phpunit
统计信息
- 总下载量: 3.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 19
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-30