Home >PHP Framework >Laravel >About the role of @ in laravel routing configuration

About the role of @ in laravel routing configuration

藏色散人
藏色散人forward
2020-03-25 08:50:502833browse

About the role of @ in laravel routing configuration

Controller action mode

URL::action('LoginController@index')

This method automatically generates the uri mapped to the controller method based on the 'uses' parameter when registering the route

Route::controller('login','LoginController');

The result is similar to:

Route::get('login',['uses'=>'LoginController@getIndex']);
Route::get('login/edit',['uses'=>'LoginController@getEdit']);
Route::post('login/edit',['uses'=>'LoginController@postEdit']);

There is no difference between the two writing methods. uses is often used with as to specify the routing name for the controller action

Route::get('user/login', [
'as' => 'login', 'uses' => 'LoginController@getIndex'
]);
return redirect()->route('login');

Recommended: laravel tutorial

The above is the detailed content of About the role of @ in laravel routing configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete