systream / router

Router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Router

Installation

You can install this package via packagist.org with composer.

composer require systream/router

composer.json:

"require": {
    "systream/router": "1.*"
}

This library requires php 5.6 or higher, but also works on php 5.4.

Usage

Setup routing

$route = new Router();
$route->addRoute(new SimpleRouting('/foo', new TestController()));
$route->addRoute(new SimpleRouting('/foo/{id}', new TestController2()));
$route->addRoute(new PathBasedRouting('app/Controller/Api', '\MyAppNamespace\Controller\Api'));
$route->addRoute(new FinalMatchRouting(new NotFoundController()));
$serverRequest = ServerRequestFactory::fromGlobals();
$route->dispatch($serverRequest, new SapiEmitter());

Test

Build Status

About

Router

License:MIT License


Languages

Language:PHP 100.0%