我是Laravel的新手并且正在探索现有的项目代码。在路线中,我找到了以下表达式:
路由:: get(' /',[' as' =>' index','使用' => ' SomeController @的someMethod']);
有人可以澄清这个表达式数组的第二个参数 - [' as' => ' index','使用' => ' SomeController @的someMethod'?]
我无法在官方文档中找到它的描述:https://laravel.com/docs/5.5/routing
答案 0 :(得分:2)
as
是route name。您可以使用它与route()
帮助程序建立链接。
uses
是一项行动。它是一个将要执行的控制器和方法。
您可以在old docs中看到一个示例:
Route::get('user/profile', [
'as' => 'profile', 'uses' => 'UserController@showProfile'
]);
答案 1 :(得分:0)
' as'部分用于"命名路线"所以你可以通过它的名字访问路线。 Laravel Documentation
&#39>使用'部分说"在SomeController中使用someMethod方法"并采用该方法做任何事情。