您好,欢迎访问一九零五行业门户网

laravel中路由的代码实例介绍

这篇文章给大家介绍的内容是关于laravel中路由的代码实例介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
路由简介
请求转化给程序
作用:url和程序之间的映射
请求方式post get put patch delete 
eg:
//get请求route::get('basic1',function(){ return 'hello world';});//多种请求//指定请求方式route::match(['get','post'],'match',function(){ return 'match';});//不指定route::any('any',function(){ return 'any';});//路由参数route::get('user/{id}',function($id){ return 'user-'.$id;});route::get('user/{id?}/{name?}',function($id,$name){ return 'user-name-'.$name;})->where(['id'=>'[0-9]+','name'=>'[a-za-z]+']);//请求的路由 http://localhost/public/user/1/w
//路由的别名route::get('user/member-center',['as'=>'center',function(){ return route('center');}]);//路由群组//prefix 前缀route::group(['prefix'=>'member'],function(){ route::get('user/center',['as'=>'center',function(){ return route('center'); }]); route::get('user/person',['as'=>'person',function(){ return route('person'); }]);});//路由中输出viewroute::get('view', function () { return view('welcome'); });
以上就是本篇文章的全部内容了。
相关推荐:
laravel5.5中如何自定义日志行为的解析
laravel5.5框架中视图间如何共享数据?视图间共享数据的两种方法(附代码)
以上就是laravel中路由的代码实例介绍的详细内容。
其它类似信息

推荐信息