laravel路由
laravel路由的路由文件路径:
有的版本是app/http/routes.php
有的版本是routes/web.php
//简单路由
Route::get('/', function () {return view('welcome');});
//访问路径 http://localhost/laravel/public/
Route::get('hello',function(){return 'hello world';});
//访问路径 http://localhost/laravel/public/hello
//不同请求方式的路由
Route::match(['get','post'],'basic2',function(){return 'basic2';});
Route::any('basic3',function(){return 'basic3';});
//传参路由
Route::get('user/{id}',function($id){
return 'user-id='.$id;
});
//访问路径 http://localhost/laravel/public/user/参数
//路由群组
Route::group(['prefix'=> 'user'], function(){
Route::any('basic2',function(){
return 'user-basic2';
});
Route::any('basic3',function(){
return 'user-basic3';
});
});
//访问路径 http://localhost/laravel/public/user-basic2/参数