voodoo / module
Module manager package
1.0.0
2019-07-22 16:11 UTC
Requires
- psr/container: ^1.0
Requires (Dev)
- codeception/codeception: ^3.0
This package is auto-updated.
Last update: 2025-03-06 23:35:09 UTC
README
This package provides an implementation of the plugin pattern.
Quick start
A module must implement Voodoo\Module\Contracts\ModuleInterface
and/or implement one of the ProviderInterfaces specified in that
namespace.
The ModuleManager manages Modules and resolves them by using an implementation of ModuleResolverInterface
<?php $modules = [ FirstModule::class, SecondModule::class, ]; $container = new DiContainer(); $resolver = new \Voodoo\Module\ContainerModuleResolver($container); $moduleManager = new \Voodoo\Module\ModuleManager($modules, $resolver); // calls di() method on modules implementing DiProvider $diConfig = $moduleManager->getContainerConfiguration(); // calls routes() method on modules implementing RouteProvider $routerConfig = $moduleManager->getRouterConfiguration(); // calls configuration() method on modules implementing ConfigurationProvider $moduleConfig = $moduleManager->getModuleConfiguration(); // calls events() method on modules implementing EventProvider $eventConfig = $moduleManager->getEventConfiguration(); // calls middleware() method on modules implementing MiddlewareProvider $middleware = $moduleManager->getMiddlewareConfiguration(); // calls bootstrap($container) modules $moduleManager->bootstrapModules($container);
This is what a module looks like:
<?php use Voodoo\Module\Contracts\DiProvider; use Voodoo\Module\Contracts\RouteProvider; use Voodoo\Module\Contracts\MiddlewareProvider; class FirstModule implements DiProvider, RouteProvider, MiddlewareProvider { public function bootstrap(ContainerInterface $container) { // Some bootstrapping code for this module } public function di() : array { return []; } public function routes() : array { return []; } public function middleware() : array { return []; } }