/** * Application constructor * * @access public * * @param $config */ public function __construct($config) { try { Service::setSimple('config', $this->config = (require_once $config)); Service::set('request', 'Framework\\Request\\Request'); Service::setSingleton('router', $this->router = new Router()); Service::setSingleton('session', Sessions::getInstance()); Service::setSingleton('dataBase', DataBase::getInstance()); Service::set('security', 'Framework\\Security\\Security'); Service::setSingleton('flushMessenger', 'Framework\\FlushMessenger\\FlushMessenger'); Service::set('app', $this); } catch (ServiceException $e) { } catch (\Exception $e) { } finally { if (isset($e)) { $code = isset($code) ? $code : 500; $errorMessage = isset($errorMessage) ? $errorMessage : 'Sorry for the inconvenience. We are working to resolve this issue. Thank you for your patience.'; $responce = MainException::handleForUser($e, array('code' => $code, 'message' => $errorMessage)); $responce->send(); } } }