zendframework/zend-config-aggregator

Name: zend-config-aggregator

Owner: Zend Framework

Description: Aggregate and merge configuration from a variety of sources.

Created: 2016-12-08 21:59:56.0

Updated: 2018-01-14 19:57:25.0

Pushed: 2018-01-05 22:50:13.0

Homepage: null

Size: 588

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

zend-config-aggregator

Build Status Coverage Status

Aggregates and merges configuration, from a variety of formats. Supports caching for fast bootstrap in production environments.

Usage

The standalone ConfigAggregator can be used to merge PHP-based configuration files:

Zend\ConfigAggregator\ConfigAggregator;
Zend\ConfigAggregator\PhpFileProvider;

regator = new ConfigAggregator([
new PhpFileProvider('*.global.php'),


dump($aggregator->getMergedConfig());

Using this provider, each file should return a PHP array:

b.global.php
rn [
'db' => [
    'dsn' => 'mysql:...',
],    


ache.global.php
rn [
'cache_storage' => 'redis',
'redis' => [ ... ],

Result:

y(3) {
b' =>
ray(1) {
'dsn' =>
string(9) "mysql:..."

ache_storage' =>
ring(5) "redis"
edis' =>
ray(0) {
 ...


Configuration is merged in the same order as it is passed, with later entries having precedence.

Together with zend-config, zend-config-aggregator can be also used to load configuration in different formats, including YAML, JSON, XML, or INI:

Zend\ConfigAggregator\ConfigAggregator;
Zend\ConfigAggregator\ZendConfigProvider;

regator = new ConfigAggregator([
new ZendConfigProvider('config/*.{json,yaml,php}'),

For more details, please refer to the documentation.



This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.