Home > PHP Framework > Laravel > body text

About the role of @ in laravel routing configuration

藏色散人
Release: 2020-03-25 08:50:50
forward
2603 people have browsed it

About the role of @ in laravel routing configuration

Controller action mode

URL::action('LoginController@index')
Copy after login

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

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

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']);
Copy after login

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');
Copy after 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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!