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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Aggregates and merges configuration, from a variety of formats. Supports caching for fast bootstrap in production environments.
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.