Dispatcher converts Requests into controller actions. It uses the dispatched Request to locate and load the correct controller. If found, the requested action is called on the controller
A factory for creating dispatchers with all the desired middleware connected.
This abstract class represents a filter to be applied to a dispatcher cycle. It acts as an event listener with the ability to alter the request or response as needed before it is handled by a controller or after the response body has already been built.
Subclasses of this class use a class naming convention having a Filter suffix.
By using the for option you can limit with request paths a filter is applied to.
Both the before and after event will have the same conditions applied to them. For
example, if you only wanted a filter applied to blog requests you could do:
$filter = new BlogFilter(['for' => '/blog']);
When the above filter is connected to a dispatcher it will only fire
its beforeDispatch and afterDispatch methods on requests that start with /blog.
The for condition can also be a regular expression by using the preg: prefix:
$filter = new BlogFilter(['for' => 'preg:#^/blog/\d+$#']);
In addition to simple path based matching you can use a closure to match on arbitrary request or response conditions. For example:
$cookieMonster = new CookieFilter([
'when' => function ($req, $res) {
// Custom code goes here.
}
]);
If your when condition returns true the before/after methods will be called.
When using the for or when matchers, conditions will be re-checked on the before and after
callback as the conditions could change during the dispatch cycle.
Provides features for building routes inside scopes.
Gives an easy to use way to build routes and append them into a route collection.
Contains a collection of routes.
Provides an interface for adding/removing routes and parsing/generating URLs with the routes it contains.
Parses the request URL into controller, action, and parameters. Uses the connected routes to match the incoming URL string to parameters that will allow the request to be dispatched. Also handles converting parameter lists into URL strings, using the connected routes. Routing allows you to decouple the way the world interacts with your application (URLs) and the implementation (controllers and actions).
Connecting routes is done using Router::connect(). When parsing incoming requests or reverse matching parameters, routes are enumerated in the order they were connected. For more information on routes and how to connect them see Router::connect().
Provides the requestAction() method for doing sub-requests