当前位置:网站首页>Routing in laravel framework
Routing in laravel framework
2022-07-05 13:49:00 【Weichi Begonia】
Common methods in routing
laravel The routes in the framework are defined in routes/web.php in , Commonly used Route Class get/ any/ match Method to define the route , among any/match All support multiple request modes ,group Method can be used to define routing groups , such as :
Route::get('integration', function () {
return "hello world";
});In the above code get Method requires two parameters , One is url Address (integration The front frame will be automatically added and defined in xampp Medium url Address ), One is function, Inside is the value we need to return or view.
If it is view, It can be defined as this :
Route::get('/', function () {
return view('welcome');
});laravel Common methods defined by the middle road :
1. get Method : ditto
2. any Method ( Multi route request ): That is, this route can be triggered in any way , such as :
Route::any('multi2', function(){
return "multi2";
});3. match Method ( Multi route request ):
Route::match(['get', 'post'], 'multi1', function(){
return 'multi1'; // This route supports get/post Way to trigger
});3. routing group
Route::group(['prefix'=>"member"], function(){
// The following routes will all have member Prefix
Route::get('user/center', ['as'=>'center', function(){
return route('center');
}]);
Route::any('multy2', function(){
return "group-multi2";
});
});How to add parameters to a route ?- The wonderful use of braces {}
Route::get("user/{id}/{name?}", function($id,$name=null){
return "User-yingkun-".$id."-".$name;
});How to add some parameter restrictions to the route ? -- Use where Method
Route::get("user/{id}/{name}", function($id, $name){
return "User-" . $id . "-name-" . $name;
})->where(["id"=>"\d+", "name"=>"[A-Za-z]+"]);Routing alias
Route::get("user/member-center", ["as"=>"center", function(){
// return "member-center";
return route('center'); // route The function is used to generate the specified route url Address of the
}]);
边栏推荐
- Zibll theme external chain redirection go page beautification tutorial
- Intranet penetration tool NetApp
- 运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
- What are the private addresses
- 几款分布式数据库的对比
- 【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
- Kafaka log collection
- 内网穿透工具 netapp
- Those things I didn't know until I took the postgraduate entrance examination
- Jasypt configuration file encryption | quick start | actual combat
猜你喜欢
![[server data recovery] a case of RAID5 data recovery stored in a brand of server](/img/04/c9bcf883d45a1de616c4e1b19885a5.png)
[server data recovery] a case of RAID5 data recovery stored in a brand of server

Mmseg - Mutli view time series data inspection and visualization

Kotlin协程利用CoroutineContext实现网络请求失败后重试逻辑

laravel-dompdf导出pdf,中文乱码问题解决

The real king of caching, Google guava is just a brother

Idea设置方法注释和类注释

Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails

Win10 - lightweight gadget

FPGA learning notes: vivado 2019.1 add IP MicroBlaze
Jetpack Compose入门到精通
随机推荐
Etcd database source code analysis -- rawnode simple package
Embedded software architecture design - message interaction
Resttemplate details
Zhubo Huangyu: it's really bad not to understand these gold frying skills
Address book (linked list implementation)
Wechat app payment callback processing method PHP logging method, notes. 2020/5/26
aspx 简单的用户登录
【 script secret pour l'utilisation de MySQL 】 un jeu en ligne sur l'heure et le type de date de MySQL et les fonctions d'exploitation connexes (3)
Log4j utilization correlation
Huawei push service content, read notes
Solution to the prompt of could not close zip file during phpword use
华为推送服务内容,阅读笔记
Record in-depth learning - some bug handling
Self built shooting range 2022
Zibll theme external chain redirection go page beautification tutorial
js 从一个数组对象中取key 和value组成一个新的对象
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
What about data leakage? " Watson k'7 moves to eliminate security threats
Idea设置方法注释和类注释
The development of speech recognition app with uni app is simple and fast.