trait HasMiddlewareTrait (View source)

Allow objects to have middleware

Methods

array
getMiddleware()

Get registered middleware

addMiddleware(string|Closure|MiddlewareInterface|array $middleware)

Add middleware.

add(string|Closure|MiddlewareInterface|array $middleware)

Alias for addMiddleware.

ResponseInterface
executeMiddleware(array $middleware, Request $request, Closure $next)

Execute an array of middleware recursively (last in, first out)

Details

array getMiddleware()

Get registered middleware

Return Value

array

HasMiddlewareTrait addMiddleware(string|Closure|MiddlewareInterface|array $middleware)

Add middleware.

Accepts: a class name, an instance of a class, a Closure or an array of any of the previous

Parameters

string|Closure|MiddlewareInterface|array $middleware

Return Value

HasMiddlewareTrait $this

Exceptions

Exception

HasMiddlewareTrait add(string|Closure|MiddlewareInterface|array $middleware)

Alias for addMiddleware.

Parameters

string|Closure|MiddlewareInterface|array $middleware

Return Value

HasMiddlewareTrait $this

ResponseInterface executeMiddleware(array $middleware, Request $request, Closure $next)

Execute an array of middleware recursively (last in, first out)

Parameters

array $middleware
Request $request
Closure $next

Return Value

ResponseInterface