laravel-best-practices
laravel-best-practices copied to clipboard
URI naming convertion?
E.g.: $router->get('/users/forgot_password', 'UserController@forgotPassword'); or $router->get('/users/forgot-password', 'UserController@forgotPassword'); or $router->get('/users/forgotPassword', 'UserController@forgotPassword');
there's no clue in Resource Controllers doc, but I guess forgot-password seems to be the way to go.
E.g.: $router->get('/users/forgot_password', 'UserController@forgotPassword'); or $router->get('/users/forgot-password', 'UserController@forgotPassword'); or $router->get('/users/forgotPassword', 'UserController@forgotPassword');
there's no clue in Resource Controllers doc, but I guess forgot-password seems to be the way to go.
$router->get('/users/forgot-password', 'UserController@forgotPassword');
URL часто регистронезависимый
case insensitive + str_slug str_slug(forgot_password) -> forgot-password
But why "named route" uses snake_case ?
For named routes is something that is not exposed to the user, and I think we mainly want snake case there because is easier to copy/paste(?), URIs are and these seems to be easier to read for most users I think. Hyphens are the standard across the web for URIs.
Is a good point though might be easier to remember, in exchange of say not being able to double click to select and copy/paste it.
@anandiamy
@anandiamy
I see several reasons:
- In a text editor, to select a whole phrase, you need to double-click the mouse. The phrase should be separated by the symbol "_", and not "-" (depending on the settings).
- Most often use short names with one verb or noun.
@anandiamy URLs are not related to Laravel, so you can use any of them. Personally, I prefer to use -
.
As for routes and similar Laravel related stuff, I prefer to use _
for the reasons @poncianodiego and @dios-oleg were talking about. Some developers don't like it and currently, there is voting here https://github.com/alexeymezenin/laravel-best-practices/pull/24
I've updated the misleading name Named Route
to Route name
to avoid similar confusion.