laminas / laminas-modulemanager

Modular application system for laminas-mvc applications
https://docs.laminas.dev/laminas-modulemanager/
BSD 3-Clause "New" or "Revised" License
30 stars 18 forks source link

RFC: ModuleManager v3 changes proposal #3

Open weierophinney opened 4 years ago

weierophinney commented 4 years ago

I intend to make a prototype for v3 that looks more like a ConfigAggregator hybrid with module manager benefits. I think it will improve the way module manager works with zend-mvc applications that also have console applications, and will make module manager more easily reusable in different contexts.

Expected usage is much like with Expressive:

use Zend\ConfigAggregator\ArrayProvider;
use Zend\ConfigAggregator\PhpFileProvider;
use Zend\ModuleManager\ModuleManager;

$cacheConfig = [
    'config_cache_path' => 'data/config-cache.php',
];
$moduleManager = new ModuleManager([
    // Include cache configuration
    new ArrayProvider($cacheConfig),
    // Framework stuff
    \Zend\Mvc\Module::class,
    \Zend\Router\Module::class,

    // Mvc module that is only providing config can be a regular config provider
    Application\ConfigProvider::class,

    new PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
    new PhpFileProvider('config/development.config.php'),
], $cacheConfig['config_cache_path']);
return $moduleManager->loadModules()->getMergedConfig();

$container = require 'config/container.php';
$app = $container->get(\Zend\Mvc\Application::class);
$app->bootstrap()->run();

Originally posted by @Xerkus at https://github.com/zendframework/zend-modulemanager/issues/79

weierophinney commented 4 years ago

I might need to remove the concept of module name to allow config providers, module instances in a way that would not be annoying or error-prone. It would be rather bad:

$moduleManager = new ModuleManager([
    // Include cache configuration
    'cache_config' => new ArrayProvider($cacheConfig),
    // Framework stuff
    \Zend\Mvc\Module::class,
    \Zend\Router\Module::class,

    // Mvc module that is only providing config can be a regular config provider
    'Application' => Application\ConfigProvider::class,

    'glob_config' => new PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
    'dev_config' => new PhpFileProvider('config/development.config.php'),
], $cacheConfig['config_cache_path']);

Eg, if I forgot to specify keys for PhpFileProvider instances, what would be the module name? Module manager tracks stuff that is already loaded by module name. Result might be... interesting.


Originally posted by @Xerkus at https://github.com/zendframework/zend-modulemanager/issues/79#issuecomment-348745070