weew / router-routes-invoker-container-aware
Container aware routes invoker for the weew/router package.
Requires
- weew/container: ^1.0
- weew/helpers-string: ^1.1
- weew/http: ^1.7
- weew/router: ^2.0
Requires (Dev)
- phpunit/phpunit: ^4.7
- satooshi/php-coveralls: ^0.6.1
This package is not auto-updated.
Last update: 2024-11-05 22:15:57 UTC
README
Table of contents
Installation
composer require weew/router-routes-invoker-container-aware
Introduction
This package is meant to be used in combination with weew/router. It's job is to invoke routes that have been successfully matched by the router. It uses the weew/container package to provide dependency injection.
Usage
Lets say you have successfully matched a route:
$route = $router->match(HttpRequestMethod::GET, new Url('foo-bar'));
Now you have to invoke the matched route:
$routesInvoker = new RoutesInvoker(new Container()); $response = $routesInvoker->invoke($route); $response->send();
If response object implements either the IHttpResponseHolder
or IHttpResponseable
interface, invoker will extract the http response and return it instead.
Router returns null
whenever a route could not be matched. In this case, RoutesInvoker
will return a 404 HttpResponse
object instead.