weew/router-routes-invoker-container-aware

Container aware routes invoker for the weew/router package.

v1.4.1 2016-07-21 11:18 UTC

This package is not auto-updated.

Last update: 2024-11-19 22:30:03 UTC


README

Build Status Code Quality Test Coverage Version Licence

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.