承接 devture/silex-provider-config 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

devture/silex-provider-config

最新稳定版本:2.0

Composer 安装命令:

composer require devture/silex-provider-config

包简介

Silex (Pimple) provider for configuration management

README 文档

README

A configuration provider for the Silex micro-framework.

Usage

The configuration loader uses the concept of configuration files (containing the configuration skeleton) and parameter files (variables that customize the configuration).

Moving some configuration values outside of the config skeleton allows config files to be commited to version control and remain identical everywhere, while leaving certain "parameters" up for customization.

Parameter files can be provided to the library as file paths or as PHP arrays of values. The latter is useful whenever you want to grab some environment variables.

Example configuration:

//config.json
{
        "key": "value",
        "something": "%something%",
        "websites": {
                "first": "%main_website%",
                "second": "%another_website%"
        }
}

//parameters.json
{
        "something": "value for something",
        "main_website": "http://devture.com/",
        "another_website": "http://github.com/spantaleev"
}

Usage:

    <?php
    $app->register(new \Devture\SilexProvider\Config\ServicesProvider());

    $configFiles = array('/path/to/config.json');

//Each is either a path to a parameter file (JSON) or an array of parameters (key => value dictionary).
    $parameterFiles = array(
    '/path/to/parameters.json',
    array('something' => 'overriden value for something'),
);

    $app['config'] = $app['devture_config.loader']->load($configFiles, $parameterFiles);

Result:

$app['config'] = array(
        'key' => 'value',
        'something' => 'overriden value for something',
        'websites' => array(
                'first' => 'http://devture.com/',
                'second' => 'http://github.com/spantaleev',
        )
);

Limitations

  • Only JSON config files an inline arrays are supported (intentional)
  • Partial parameter replacements are not supported ("storage_path": "%base_path%/storage") - may be implemented later

统计信息

  • 总下载量: 3.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD
  • 更新时间: 2013-02-23