Controller Naming Convention in Laravel 5

All controllers in Laravel 5 are still called the suffix Controller, for example, AuthControllerand PasswordController. Is there any reason to follow this agreement with my own controllers, or are these suffixes left over from the era preceding the names?

I use action-based URL generation most of the time, so I avoid linking like url('home'), but instead I prefer something like action('HomeController@index). This way I can change the URL patterns without a headache.

But action('Home@index')so elegant. Any traps behind him?

+4
source share
3 answers

There is no need to add a controller suffix. If it was really necessary, when you create the Controller through a craftsman, he automatically adds it or complains about it, but this is not so. So, don't be shy (but keep in mind that if you want a Dog controller and there is a Dog model ... well, that will be difficult).

+3
source

. . . Home HomeController. action('Home@index') . Laravel - . , . . Controller , . use home use app\home . .

0

Controller . , . DogController Dog. , , DogController.

, App\Http\Controllers\DogController, , ? , PHP use App\Http\Controllers\DogController;, DogController .

, Laravel . , , Laravel , , Laravel .

0

Source: https://habr.com/ru/post/1605706/


All Articles