settings = $settings; $this->viewPath = $settings->get('view.path', APP_PATH . '/Views'); // If not set, compute default if (!is_dir($this->viewPath)) { $this->viewPath = __DIR__ . '/../../Views'; } } /** * Render a view and return its output. * * @param string $view Name of the view file (without .php) * @param array $data Data to extract into the view * @return string Rendered view output */ public function make(string $view, array $data = []): string { $viewFile = $this->viewPath . '/' . str_replace('.', '/', $view) . '.php'; if (!is_file($viewFile)) { // Try with default extension $viewFile = $this->viewPath . '/' . str_replace('.', '/', $view) . '.php'; if (!is_file($viewFile)) { return "View [{$view}] not found."; } } // Extract data to local variables extract($data, EXTR_SKIP); // Start output buffering ob_start(); try { include $viewFile; } catch (\Throwable $e) { ob_end_clean(); return "Error rendering view: " . $e->getMessage(); } return ob_get_clean(); }}