But where to put the code?
I have the modules:
class Module implements ModuleDefinitionInterface {
public function registerServices(DiInterface $di) {
$di->set('dispatcher', function () use ($di) {
$eventsManager = new EventsManager;
$eventsManager->attach('dispatch:beforeDispatch', new SecurityPlugin);
$dispatcher = new Dispatcher;
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
}
}
And I have the bootstrap (index.php):
try {
require '../vendor/autoload.php';
$di = new FactoryDefault();
$di->set('dispatcher', function () use ($di) {
$eventsManager = new EventsManager;
$eventsManager->attach('dispatch:beforeDispatch', new SecurityPlugin);
$dispatcher = new Dispatcher;
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
$application = new Application($di);
$application->registerModules([
'frontend' => [
'className' => 'Run\Frontend\Module',
'path' => '../app/frontend/Module.php'
],
'backend' => [
'className' => 'Run\Backend\Module',
'path' => '../app/backend/Module.php'
]
]);
require '../app/services/filters.php';
echo $application->handle()->getContent();
} catch (\Exception $e) {
echo "Exception: ", $e->getMessage();
}