public final function run() { if (!$this->config) { throw new \RuntimeException('Call setConfig() first to get run application!'); } // re-set app as global set_global('app', $this); $this->request = new Request(); $this->response = new Response(); // set application defaults $this->setDefaults(); // security & performans checks if ($halt = $this->haltCheck()) { $this->halt($halt); } // hold output buffer $this->startOutputBuffer(); $this->service = (new ServiceAdapter($this))->getService(); // sessions used for only "site" if ($this->service->protocol == ServiceInterface::PROTOCOL_SITE) { $this->session = Session::init($this->config['app.session.cookie']); } if (!$this->service->isAllowedRequestMethod($this->request->method)) { // set fail stuff $this->response->setStatus(Status::METHOD_NOT_ALLOWED); $this->response->setContentType(ContentType::NONE); $output = ''; } else { $output = $this->service->run(); } // end output buffer $this->endOutputBuffer($output); }