Usage

use Robopuff\ConfigAggregator\ClassProvider\ClassDiscoveryProvider;
use Zend\ConfigAggregator\ConfigAggregator;

$aggregator = new ConfigAggregator([
    new ClassDiscoveryProvider(__DIR__ . '/src/{Dir1,Dir2}/*/ConfigProvider.php'),
    new ClassDiscoveryProvider([
        '/src/Dir1/*/ConfigProvider.php',
        '/src/Dir2/*/ConfigProvider.php'
    ]),
]);

return $aggregator->getMergedConfig();

Modes

By default ClassDiscoveryProvider will be working using PREG method of discovering fully qualified class name, this can be changed to:

Setting options

Be aware that options set in class constructor extend settings set as default.

Global

use Robopuff\ConfigAggregator\ClassProvider\ClassDiscoveryProvider;
use Zend\ConfigAggregator\ConfigAggregator;

// Set up default for each instance of class
ClassDiscoveryProvider::setDefaultOptions([
    'mode' => ClassDiscoveryProvider::METHOD_PATH
])

$aggregator = new ConfigAggregator([
    new ClassDiscoveryProvider(__DIR__ . '/src/*/ConfigProvider.php', [
        'baseSrc' => __DIR__ . '/src',
        'prefix' => 'Random\\Namespace\\'
    ]),
]);

return $aggregator->getMergedConfig();

Per instance

use Robopuff\ConfigAggregator\ClassProvider\ClassDiscoveryProvider;
use Zend\ConfigAggregator\ConfigAggregator;

$aggregator = new ConfigAggregator([
    new ClassDiscoveryProvider('src/*/ConfigProvider.php', [
        'mode' => ClassDiscoveryProvider::METHOD_PATH,
        'baseSrc' => 'src',
        'prefix' => 'Random\\Namespace\\'
    ]),
]);

return $aggregator->getMergedConfig();