make: Why is the use App\Http\Requests written in the controller?

Asked 2 years ago, Updated 2 years ago, 96 views

When you create a controller with the command,

use App\Http\Requests;

Why does it come with ?It works even if you erase it as a trial.
Do you expect any expansion?I would appreciate it if you could let me know if you can use Ravel 5.

php laravel laravel-5

2022-09-30 11:03

1 Answers

Laravel 5 now allows validation of input values using FormRequest.The namespace where this FormRequest is placed is App\Http\Requests.

When you generate the controller, you don't have to use FormRequest, so you can turn it off, and if you specify App\Http\Requests\HogeRequest, you don't need to use it.It's also good to use it by class.

Note: Similar opinions were mentioned in Issue

Remove dead reference from controller stubs by miclf ·Pull Request #8656 ·larvel/framework

It's to make it more convenient to type-hint Form Requests.
--- Quoted from Taylor Otwell's comments

See also


2022-09-30 11:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.