public function index(Request $request) { $response = new Response(); $content = view('news.list', ['page' => 'news']); $response->content($content); return $response; }
public function index() { $response = new Response(); $content = view('index.index', ['content' => "Главная страница"]); $response->content($content); return $response; }
public function index(Request $request) { $newsModel = new Models\NewsModel(); $onPage = 10; $page = intval($request->get('page')); $news = $newsModel->select($page, $onPage); $response = new Response(); $response->header('Content-type', 'application/json')->content(json_encode(['method' => 'newslist', 'result' => ['items' => $news, 'total' => 12, 'page' => $page, 'onpage' => $onPage, 'pages' => 2]])); return $response; }
public function response(Response $response) { $headers = $response->headers(); ob_clean(); foreach ($headers as $header => $value) { header("{$header}: {$value}"); } echo $response->content(); exit; }
/** * 输出HTTP异常信息 * * @param HttpException $e */ protected function renderHttpException(HttpException $e) { $message = $e->getMessage(); if (empty($message)) { $message = Response::getStatusText($e->getCode()); } $response = new Response(); $response->setStatus($e->getCode()); $response->setContent("<h1>{$message}</h1>"); $response->send(); }