settings = [ 'db' => [ 'host' => $_ENV['DB_HOST'] ?? 'localhost', 'name' => $_ENV['DB_NAME'] ?? 'my_app', 'user' => $_ENV['DB_USER'] ?? 'root', 'pass' => $_ENV['DB_PASS'] ?? '', ], 'app' => [ 'name' => $_ENV['APP_NAME'] ?? 'Vanilla PHP App', 'env' => $_ENV['APP_ENV'] ?? 'production', 'debug' => ($_ENV['APP_DEBUG'] ?? 'false') === 'true', 'url' => $_ENV['APP_URL'] ?? 'http://localhost', ], 'mail' => [ 'host' => $_ENV['MAIL_HOST'] ?? 'smtp.mailtrap.io', 'port' => $_ENV['MAIL_PORT'] ?? 2525, ] ]; } public static function get(string $key, $default = null) { if (self::$instance === null) { self::$instance = new self(); } // Support dot notation (e.g., 'db.host') $keys = explode('.', $key); $value = self::$instance->settings; foreach ($keys as $k) { if (!isset($value[$k])) { return $default; } $value = $value[$k]; } return $value; } } ?>