設置的文件為:routes/web.php
最常用的用法:
調用controller的方法业岁。
Route::get('/hello', 'HelloController@index');
直接寫出方法责语。
Route::get('email',function (){
return view('email.index');
});
常用方法:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::any($uri, $callback);
any 是我自己加上去的送淆,文檔上沒寫器罐,代表可以使用所有方法。
$uri 參數(shù)前面加不加 / 的區(qū)別:
以 localhost 為例:
有 / 代表根目錄訪問格侯,比如只能訪問 localhost/hello
沒有 / 代表相對目錄訪問搁廓,可以訪問任何目錄下的email,如 localhost/email诵冒,localhost/otherPage/email
參考:HTTP 路由抓狭。