2017 © Pedro Peláez
 

library zf2-dynamic-modules

Dynamic module loader for ZF2

image

saeven/zf2-dynamic-modules

Dynamic module loader for ZF2

  • Friday, October 16, 2015
  • by Saeven
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Dynamic Module Loader

I needed a means to dynamically wire modules into ZF2. This overrides the ModuleManager to create a system where closure conditions can be used to modify the application config's module array., (*1)

Configuration is very simple, and is done in your application.config.php, not in your module config!, (*2)

Installation

composer require saeven/zf2-dynamic-modules

application.config.php

return [

    'service_manager' => [
        'factories' => [
            'ModuleManager' => 'CirclicalModuleLoader\Service\Factory\ModuleManagerFactory',
        ],
    ],

    'modules_conditional' => [
        'SomeModule' => function(){ return true; }
    ],

    'modules' => [

        // usual modules

    ],

    'module_listener_options' => [
        'config_glob_paths' => [
            'config/autoload/{,*.}{global,local}.php',
        ],
        'module_paths' => [
            './module',
            './vendor',
        ],
    ],
];

The magic happens in the closure that accompanies the modules_conditional array. Your closure would return true or false based on environment conditions., (*3)

Todo - this was done to conditionally load modules based on route, and perhaps, based on database data., (*4)

The Versions

16/10 2015

dev-master

9999999-dev https://github.com/Saeven/zf2-dynamic-modules

Dynamic module loader for ZF2

  Sources   Download

MIT

The Requires

  • php >=5.5

 

form zf2 zend framework forms generate