public function handle($e) { $this->logException($e); if ($this->isExceptionHalting($e)) { // if headers are sent, we can't send a response if (headers_sent()) { echo $this->buildResponseBody($e); exit(0); } // send it off $sender = new Http\ResponseSender($this->buildResponse($e)); $sender->send(); if (ob_get_level() > 0) { ob_flush(); } exit(self::EXIT_CODE); } }
/** * Processes an HTTP request, copies response to STDOUT * @return void */ public function run($server = null, $stream = null) { $server = $server ?: $_SERVER; $stream = $stream ?: fopen('php://output', 'w'); $controller = $this->controller(); // build up wrappers of middleware foreach ($this->_middleware as $middleware) { $controller = new $middleware($controller, $this); } $requestFactory = new Http\RequestFactory($server); $response = $controller->execute($requestFactory->create()); $sender = new Http\ResponseSender($response, $stream); $sender->send(); }