https://github.com/zendframework/zend-config-aggregator
Aggregate and merge configuration from a variety of sources.
https://github.com/zendframework/zend-config-aggregator
Last synced: 7 months ago
JSON representation
Aggregate and merge configuration from a variety of sources.
- Host: GitHub
- URL: https://github.com/zendframework/zend-config-aggregator
- Owner: zendframework
- License: bsd-3-clause
- Archived: true
- Created: 2016-12-08T21:59:56.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T14:48:12.000Z (almost 6 years ago)
- Last Synced: 2024-04-12T02:25:46.505Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 1.56 MB
- Stars: 44
- Watchers: 19
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# zend-config-aggregator
> ## Repository abandoned 2019-12-31
>
> This repository has moved to [laminas/laminas-config-aggregator](https://github.com/laminas/laminas-config-aggregator).
[](https://secure.travis-ci.org/zendframework/zend-config-aggregator)
[](https://coveralls.io/github/zendframework/zend-config-aggregator?branch=master)
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:
```php
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:
```php
// db.global.php
return [
'db' => [
'dsn' => 'mysql:...',
],
];
// cache.global.php
return [
'cache_storage' => 'redis',
'redis' => [ ... ],
];
```
Result:
```php
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:
```php
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](https://docs.zendframework.com/zend-config-aggregator/).
-----
- File issues at https://github.com/zendframework/zend-config-aggregator/issues
- Documentation is at https://docs.zendframework.com/zend-config-aggregator/