Example #1
0
 /**
  * Application constructor. This is the entry point of Calmacil/Mf.
  * @param string $root
  * @param string $env
  */
 public function __construct($root, $env = 'prod')
 {
     parent::__construct($root);
     define('ROOT', $root);
     $this->env = $env;
     $this->cfile = "settings_" . $this->env;
     Config::init(ROOT . '/config/');
     // Loggers
     $rotateHandler = new RotatingFileHandler(ROOT . Config::get($this->cfile)->log->logfile, 10, Config::get($this->cfile)->log->loglevel);
     $processor = new PsrLogMessageProcessor();
     $this->loggers['core'] = new Logger('core');
     $this->loggers['app'] = new Logger('app');
     $this->loggers['core']->pushHandler($rotateHandler);
     $this->loggers['app']->pushHandler($rotateHandler);
     $this->loggers['core']->pushProcessor($processor);
     $this->loggers['app']->pushProcessor($processor);
     if (Config::get($this->cfile)->debug) {
         $browserHandler = new BrowserConsoleHandler();
         $this->loggers['core']->pushHandler($browserHandler);
         $this->loggers['app']->pushHandler($browserHandler);
     }
     $this->coreLogger()->addNotice("============================================================");
     // Session service handling
     if (session_status() !== PHP_SESSION_DISABLED) {
         $this["session"] = new SessionPlugin($this);
     }
     $this->router = Router::getInstance(ROOT . Config::get($this->cfile)->paths->routing_file, $this);
     $this->request = new Request($this, $_SERVER['REQUEST_URI']);
     $this->response = new Response($this);
     $this->coreLogger()->addNotice("------------------------------------------------------------");
     $this->coreLogger()->addNotice("Application initialized.");
 }