Home > Backend Development > PHP Tutorial > laravel控制器使用中间件

laravel控制器使用中间件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:13:03
Original
1297 people have browsed it


官方文档写的比较简单,只用如下就行了,但你使用过程中是会报错的,因为还没建立对应关系

public function __construct(){    $this->middleware('wechatapi');}
Copy after login

打开app/Http/Kernel.php

protected $routeMiddleware = [    'auth' => \App\Http\Middleware\Authenticate::class,    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,    'wechatapi'=>\App\Http\Middleware\WechatApi::class,];
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template