Blogger Information
Blog 28
fans 0
comment 0
visits 19696
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1108 laravel框架下 中间件的创建 20191108 2000-2200
没有人的夏天的博客
Original
846 people have browsed it

中间件控制

中间件的创建

  1. php artisan make:middleware test\Clk

clk.php文件 handle方法中添加

  1. exit("hello widdleware");

中间件的注册

app\http\kermel.php 文件中 routemiddleware 属性添加

  1. protected $routeMiddleware = [
  2. // 自定义中间件
  3. 'clk' => \App\Http\Middleware\test\Clk::class,
  4. ];

中间件的触发

web.php中指定路由调用 middleware方法

  1. Route::get('/home', 'home@index')->middleware('clk');

效果图

Correction status:qualified

Teacher's comments:合格
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