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のControllerって何?

0
Last updated at Posted at 2025-12-29

LaravelのControllerについて学んだのでその役割についてまとめたい。

LaravelのControllerは機能を管理する場所

いわばWEBサイトやアプリで必要な機能やメソッドを管理しておく場所だ

Controllerは、「リクエストを受け取り、必要な処理を実行し、結果を返す」という流れの中心となる存在である。

機能ごとに分けることが望ましい

例えば、一つのControllerに複数の機能のコードを入れて長いコードにすることはコードの保守性、管理、バグ対策という意味でも適切ではない。

その為出来るだけコードは分けた方が良い。

Controllerの作り方

php artisan make:controller testController 

まとめ

Controllerは 機能を管理する場所

機能ごとにControllerを分けるのがベスト

長くなった処理は分割して管理する

Artisanコマンドで簡単に作成できる

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?