标签:efi 请求 user any match pre mem 路由 source
// 基础路由
Route::get(‘hello‘,function (){
return ‘hello‘;
});
Route::post(‘hello‘,function (){
return ‘hello‘;
});
// 多请求路由
Route::match([‘get‘,‘post‘],‘hello‘,function (){
return ‘hello‘;
});
// 任意请求路由
Route::any(‘world‘,function (){
return ‘world‘;
});
// 带参数路由
Route::get(‘user/{id}‘,function ($id){
return ‘User-‘.$id;
});
// 带参数和条件路由(?表示可选参数)
Route::get(‘user/{id}/{name?}‘,function ($id,$name=‘tom‘){
return ‘User-id-‘.$id.‘-name-‘.$name;
})->where([‘id‘=>‘[0-9]+‘,‘name‘=>‘[A-Za-z]+‘]);
// 别名路由(控制器等地方可用别名代替)
Route::get(‘user/my-center‘,function (){
return route(‘center‘);
})->name(‘center‘);
// 路由群组(访问xxx/member/user/my-center)
Route::group([‘prefix‘=>‘member‘],function (){
Route::get(‘user/my-center‘,function (){
return route(‘center‘);
})->name(‘center‘);
Route::any(‘world‘,function (){
return ‘world‘;
});
});
// 视图路由
Route::get(‘/‘, function () {
return view(‘welcome‘);
});
标签:efi 请求 user any match pre mem 路由 source
原文地址:https://www.cnblogs.com/toney-yang/p/9189834.html