zendframework / zend-config-aggregator
Lightweight library for collecting and merging configuration from different sources
Installs: 1 530 848
Dependents: 73
Suggesters: 2
Security: 0
Stars: 48
Watchers: 23
Forks: 13
Open Issues: 1
Requires
- php: ^5.6 || ^7.0
- zendframework/zend-stdlib: ^2.7.7 || ^3.1.0
Requires (Dev)
- malukenho/docheader: ^0.1.5
- phpunit/phpunit: ^5.7.21 || ^6.3
- zendframework/zend-coding-standard: ~1.0.0
- zendframework/zend-config: ^2.6 || ^3.0
- zendframework/zend-servicemanager: ^2.7.7 || ^3.1.1
Suggests
- zendframework/zend-config: Allows loading configuration from XML, INI, YAML, and JSON files
- zendframework/zend-config-aggregator-modulemanager: Allows loading configuration from zend-mvc Module classes
- zendframework/zend-config-aggregator-parameters: Allows usage of templated parameters within your configuration
This package is auto-updated.
Last update: 2020-01-29 14:48:17 UTC
README
Repository abandoned 2019-12-31
This repository has moved to laminas/laminas-config-aggregator.
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:
use Zend\ConfigAggregator\ConfigAggregator; use Zend\ConfigAggregator\PhpFileProvider; $aggregator = new ConfigAggregator([ new PhpFileProvider('*.global.php'), ]); var_dump($aggregator->getMergedConfig());
Using this provider, each file should return a PHP array:
// db.global.php return [ 'db' => [ 'dsn' => 'mysql:...', ], ]; // cache.global.php return [ 'cache_storage' => 'redis', 'redis' => [ ... ], ];
Result:
array(3) { 'db' => array(1) { 'dsn' => string(9) "mysql:..." } 'cache_storage' => string(5) "redis" 'redis' => array(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:
use Zend\ConfigAggregator\ConfigAggregator; use Zend\ConfigAggregator\ZendConfigProvider; $aggregator = new ConfigAggregator([ new ZendConfigProvider('config/*.{json,yaml,php}'), ]);
For more details, please refer to the documentation.
- File issues at https://github.com/zendframework/zend-config-aggregator/issues
- Documentation is at https://docs.zendframework.com/zend-config-aggregator/