Skip to content

weew/router-routes-invoker-container-aware

Repository files navigation

Routes invoker

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.

About

Container aware routes invoker for the weew/router package.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages