0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Laravelのweb.phpに関して誤解していたこと

0
Posted at

Laravelの初学者です。
web.phpについて誤解していたことをまとめます。

web.phpの役割(誤解)

ルーティングを決めるためのもの。
いわゆる、/test-page にアクセスしたらこのファイルを表示するよ、というもの。

web.phpの正しい役割

上記が間違っているわけではないんだけど、web.phpの役割はそれだけじゃない。
「HTTPリクエスト」をどのファイルで処理するかを渡すことが本来のweb.phpの役割だ。

確かに /test-pageにアクセスした時にどのファイルを表示するかを決めることもこの機能に入るし、
フォームなどのrequestメソッドに対してどの処理を返すか、といったこともweb.phpの役割になる

まとめ

web.php は単に「画面を表示するためのルーティング」ではなくHTTPリクエストと処理(Controllerなど)を結びつけるための場所である。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?