eserozvataf/scabbia2-config

该软件包已被废弃,不再维护。未建议替代软件包。

Scabbia2 配置组件

v0.1.1 2015-09-16 07:45 UTC

This package is auto-updated.

Last update: 2023-09-08 20:00:29 UTC


README

此组件是一个支持绑定多个配置文件的配置编译器。

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version Documentation Status

使用方法

合并多个配置

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);

覆盖现有配置项

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'];

在单独配置中构建列表

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']);

扁平化配置值键

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'];

链接

贡献

任何贡献都公开开放。欢迎提交错误修复、新功能和额外模块。所有贡献都应提交到eserozvataf/scabbia2-config存储库。

  • 要贡献代码:Fork 仓库,将您的更改推送到您的分支,然后提交一个 pull 请求。
  • 要报告错误:如果某些功能无法正常工作,请使用 GitHub 问题报告。
  • 要支持:Donate