Help us understand the problem. What is going on with this article?

Laravel::RequestとResponse の表示

More than 1 year has passed since last update.

条件

use文で下記の2行を追加し、 読み込むアクションの引数を指定する必要がある

(Request $request,Response $response)
use Illuminate\Http\Request;
use Illuminate\Http\Response;
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;


class HelloController extends Controller
{
    public function index(Request $request,Response $response) {

$html = <<<EOF
        <html>
        <head>
        <title>Request&Response</title>
        <style>
        body {
            font-size:16pt;
            color:#999;
        }
        h1 {
            font-size:100pt;
            text-align: right;
            color:#eee;
            margin:-40px 0 -50px 0;
        }
        </style>
        </head>
        <body>
            <h1>Hello</h1>
            <h3>Request</h3>
            <pre>{$request}</pre>
            <h3>Response</h3>
            <pre>{$response}</pre>
            <h3>アクセスしたURLを表示 url()</h3>
            <pre>{$request->url()}</pre>
            <h3>アクセスしたURLをすべて表示する fullUrl()</h3>
            <pre>{$request->fullUrl()}</pre>
            <h3>ドメイン下のパス部分だけを返す path()</h3>
            <pre>{$request->path()}</pre>
        </body>
        </html>
EOF;
        $response->setContent($html);
        return $response;
    }
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした