RoutingMiddleware
in package
implements
MiddlewareInterface
Applies routing rules to the request and creates the controller instance if possible.
Table of Contents
Interfaces
- MiddlewareInterface
- Participant in processing a server request and response.
Constants
- ROUTE_COLLECTION_CACHE_KEY = 'routeCollection'
- Key used to store the route collection in the cache engine
Properties
- $app : RoutingApplicationInterface
- The application that will have its routing hook invoked.
- $cacheConfig : string|null
- The cache configuration name to use for route collection caching, null to disable caching
Methods
- __construct() : mixed
- Constructor
- process() : ResponseInterface
- Apply routing and update the request.
- buildRouteCollection() : RouteCollection
- Check if route cache is enabled and use the configured Cache to 'remember' the route collection
- loadRoutes() : void
- Trigger the application's routes() hook if the application exists and Router isn't initialized.
- prepareRouteCollection() : RouteCollection
- Generate the route collection using the builder
Constants
ROUTE_COLLECTION_CACHE_KEY
Key used to store the route collection in the cache engine
public
string
ROUTE_COLLECTION_CACHE_KEY
= 'routeCollection'
Properties
$app
The application that will have its routing hook invoked.
protected
RoutingApplicationInterface
$app
$cacheConfig
The cache configuration name to use for route collection caching, null to disable caching
protected
string|null
$cacheConfig
Methods
__construct()
Constructor
public
__construct(RoutingApplicationInterface $app[, string|null $cacheConfig = null ]) : mixed
Parameters
- $app : RoutingApplicationInterface
-
The application instance that routes are defined on.
- $cacheConfig : string|null = null
-
The cache config name to use or null to disable routes cache
process()
Apply routing and update the request.
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Any route/path specific middleware will be wrapped around $next and then the new middleware stack will be invoked.
Parameters
- $request : ServerRequestInterface
-
The request.
- $handler : RequestHandlerInterface
-
The request handler.
Return values
ResponseInterface —A response.
buildRouteCollection()
Check if route cache is enabled and use the configured Cache to 'remember' the route collection
protected
buildRouteCollection() : RouteCollection
Return values
RouteCollectionloadRoutes()
Trigger the application's routes() hook if the application exists and Router isn't initialized.
protected
loadRoutes() : void
Uses the routes cache if enabled via configuration param "Router.cache"
If the middleware is created without an Application, routes will be loaded via the automatic route loading that pre-dates the routes() hook.
prepareRouteCollection()
Generate the route collection using the builder
protected
prepareRouteCollection() : RouteCollection