当前位置:网站首页>Laravel basic course routing and MVC - routing
Laravel basic course routing and MVC - routing
2022-06-26 01:22:00 【DJ Fry】
route
scene : Forward the user's request to the corresponding program for processing ;
effect : establish URL And procedure ( Processing function ) Mapping between ;
type :get,post,put,pathc,delete
route :app/Http/route.php
Basic routing
Route::get('get', function () {
return 'routes test get';
});
Route::post('post', function () {
return 'routes test post';
});
Multi request routing
Route::match(['get', 'post'],'match', function () {
return 'test match multy1';
});
Routing parameters
Route::get('user/{id}', function ($id) {
return 'get id is '.$id;
})->where('id','[0-9]+');
Route::get('user/{name?}', function ($name = null) {
return 'get name is '.$name;
});
Route::get('user/{name?}', function ($name = ' Set the default value ') {
return 'get name is '.$name;
});
Route::get('user/{name?}', function ($name = ' Set the default value ') {
return 'get name is '.$name;
})->where('name','[A-Za-z]+');
/* Set conditions */
Route::get('user/{name}/{id?}', function ($name = 'dename' , $id = 'deid') {
return 'get name is '.$name.' and id is '.$id;
})->where(['id'=>'[0-9]+','name'=>'[A-Za-z]+']);/* Multiple parameters where In array form */
Routing alias
Route::get('/member/member-center', ['as'=>'center',function () {
return 'member-center i am '.route('center');
}]);
routing group
route::group(['prefix'=>'member'],function (){
Route::get('user', function () {
return 'user in member';
});
Route::get('test ', function () {
return 'test in member';
});
http:localhost:8880/member/test
});
Output view in route
Route::get('view', function () {
return view('welcomeroute');
});
Route::get('view2', function () {
return view('layouts');
});
Two calls controller
Route::get('member/info', '[email protected]');
Route::get('member/info1', ['uses'=>'[email protected]']);
Alias
Route::get('member/info2', ['uses'=>'[email protected]','as'=>'memberinfo']);
Parameter binding
Route::get('member/{id}', ['uses'=>'[email protected]'])
->where('id','[0-9]+');
边栏推荐
- 制作3D浪漫炫酷相册【附源码】
- 接口的幂等性——详细谈谈接口的幂等即解决方案
- containerd客户端比较
- Inheritance -- holy grail mode
- Idea configuration
- Zhihuijia - full furniture function
- Msp430f5529lp official board (red) can not debug the problem
- A sharp tool for information collection, Google hacker syntax
- Is it safe to open a fund account? Are there any risks?
- 生信周刊第33期
猜你喜欢

新库上线 | CnOpenDataA股上市公司IPO申报发行文本数据

智慧家——全家具功能

New library launched | cnopendata China new house information data

Essence and thoughts of 30 lectures on product thinking

案例:绘制Matplotlib动态图

The kth largest element in the array

SPI protocol

vite打包构建时 @charset utf-8警告问题处理;

Data analysis slicer, PivotTable and PivotChart (necessary in the workplace)

Technical introduction - detailed explanation of chip manufacturing process
随机推荐
[机缘参悟-30]:鬼谷子-内揵篇-同理心,站在对方的立场,拉近与对方的心理距离
STM32 uses SPI mode to drive TFT-LCD optimization code of hx8347 scheme
Sqlserver is case sensitive
Online gadget sharing (updated from time to time, current quantity: 2)
Black box test - decision table method of test cases
DGUS新升级:全面支持数字视频播放功能
RT-Thread 项目工程搭建和配置--(Env Kconfig)
生信周刊第34期
安卓缓存使用工具类
Idea configuration
How to effectively promote products
【花雕体验】11 上手ESP32C3
物联网?快来看 Arduino 上云啦
黑盒测试 — 测试用例 之 判定表法看这一篇就够了
Msp430f5529lp official board (red) can not debug the problem
Using redis database as cache in Django
Is it safe to open a fund account? Are there any risks?
同花顺软件买股票进行交易安全吗?怎么开户买股票
C#线程池控制Semaphore
[Excel知识技能] Excel数据类型