/laminas-config-aggregator-modulemanager

Consume laminas-mvc modules as configuration providers within laminas-config-aggregator.

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

laminas-config-aggregator-modulemanager

Build Status Coverage Status

Provides an extension to the laminas/laminas-config-aggregator so laminas/laminas-mvc modules can be parsed into the new config structure, e.g. for mezzio/mezzio or other projects.

Usage

use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\ConfigAggregatorModuleManager\LaminasModuleProvider;
use My\Laminas\MvcModule\Module as MyLaminasMvcModule;

namespace My\Laminas\MvcModule
{
    class Module 
    {
        public function getConfig()
        {
            return [
                'service_manager' => [
                    'invokables' => [
                        Service\MyService::class => Service\MyService::class, 
                    ],
                ],
            ];
        }
    }
}

namespace My\Laminas\MvcModule\Service {
    class MyService 
    {
    }
}

$aggregator = new ConfigAggregator([
    new LaminasModuleProvider(new MyLaminasMvcModule()),
]);

var_dump($aggregator->getMergedConfig());

Using this provider, the Module class is being parsed for laminas/laminas-modulemanager interfaces or methods. Just the same way as laminas/laminas-mvc does. Therefore, the output of the example would be:

array(1) {
  'dependencies' => 
  array(1) {
    'invokables' =>
    array(1) {
       'My\Laminas\MvcModule\Service\MyService' =>
       string(35) "My\Laminas\MvcModule\Service\MyService"
    }
  }
}

For more details, please refer to the documentation.