Blogger Information
Blog 65
fans 2
comment 0
visits 60670
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
lavarel7学习笔记:中间件使用
张福根一修品牌运营
Original
730 people have browsed it

lavarel7中间件使用

中间件使用流程

Mytest.php
1、定义中间件类:自定义类名Mytest+固定方法handle
class Mytest{
public function handle(Request $request,Closure $next){
echo ‘adedssd’;
return response(‘addldkdd’,502);//不想往后执行
return $next($request);//想往后执行
}
}
2、到Kermel.php注册中间件
‘mytest’=> \App\Http\Middleware\Mytest::class,
3、触发中间件:在路由调用方法
Route::get(‘mydb/index’,’Mydb@index’)->middleware(‘mytest’);

中间件用途:比如,登录验证

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post