Laravel middleware中间件

Laravel Middleware 中间件

php artisan make:middleware TestMiddleware

public function handle($request, Closure $next)
{
if($request->input(‘id’) > 1) {
die( ‘hello world’ );
}
return $next($request);
}
注册中间件
app/Http/Kernel.php$middleware添加

控制器当中
$this->middleware(‘Test’);
路由器
Route::get(‘/’,’Test\\TestController@index’, [‘middleware’ => ‘Test’]);



Tagged , . Bookmark the permalink.

Comments are closed.