PHP code example of voodoo / module

1. Go to this page and download the library: Download voodoo/module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voodoo / module example snippets




$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);




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 [];
    }
}