public function run(FrontController $frontController) { try { // Enable output buffering. ob_start(); // Build the HTTP context data. $requestPath = $frontController->buildContext($this->configuration); // Build the controller path string for controller class autoloading. $this->controllerPath = "{$this->applicationPath}/controllers{$requestPath}"; // Execute the front controller. $frontController->run(); $frontController->renderView(); // Send HTTP response and turn off output buffering. ob_end_flush(); } catch (Exception $exception) { // Destroy any output buffer contents that could have been added. ob_clean(); $frontController->renderErrorView(implode('<br>', [$exception->getMessage(), "<strong>Fichier</strong> : " . $exception->getFile(), "<strong>Ligne</strong> : " . $exception->getLine()])); } }