Laravel如何获取所有注册的路由中间件


原文地址:Laravel如何获取所有注册的路由中间件

本篇文章分享获取Laravel所有已经在Kernel中注册的路由中间件示例代码。

获取Laravel所有已经在Kernel中注册的路由中间件,代码如下:

app(Kernel::class)->getRouteMiddleware()

Kernel.php文件是App\Http下的Kernel文件,获取已经注册的路由中间件,下面是获取已经注册的路由中间件:

protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'permission' => PermissionControl::class,
        'customer' => CustomerMiddleware::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
    ];

 

 

评论

登录后评论

服务器优惠活动

Top