/** * Application constructor. */ public function __construct($configPath) { //Registration all configuration vars in the config container Registry::setConfigsArr(include $configPath); Service::set('router', new Router(Registry::getConfig('routes'))); Service::set('dbConnection', Connection::get(Registry::getConfig('pdo'))); Service::set('request', new Request()); Service::set('security', new Security()); Service::set('session', Session::getInstance()); Service::set('renderer', new Renderer(Registry::getConfig('main_layout'))); Service::set('eventManager', EventManager::getInstance()); //Registers the events Service::get('eventManager')->registerEvent('applicationInit')->registerEvent('parseRoute')->registerEvent('dispatchAction')->registerEvent('controllerRender')->registerEvent('controllerGenerateRoute')->registerEvent('controllerRedirect')->registerEvent('sendAction')->registerEvent('renderAction'); //Attaches a new listener Service::get('eventManager')->addListener('Framework\\Logger\\Logger'); //Sets the error display mode Helper::errorReporting(); //Launches the appropriate event Service::get('eventManager')->trigger('applicationInit', "The start of application"); }