2017 © Pedro Peláez
 

library http-router

A PSR-7 / PSR-15 compatible router interface and a PSR-15 server request handler implementation for routing.

image

n1215/http-router

A PSR-7 / PSR-15 compatible router interface and a PSR-15 server request handler implementation for routing.

  • Wednesday, February 21, 2018
  • by n1215
  • Repository
  • 0 Watchers
  • 1 Stars
  • 181 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

http-router

Latest Stable Version License Build Status Code Coverage Scrutinizer Code Quality, (*1)

A PSR-7 / PSR-15 compatible router interface and a PSR-15 server request handler implementation for routing., (*2)

This package helps you to create your own http router., (*3)

Usage

<?php

// 1. Implement RouterInterface. You can use RoutingResultFactory concrete classes to create RoutingResult.
class YourRouter implements N1215\Http\Router\RouterInterface
{
    public function match(ServerRequestInterface $request) : RoutingResultInterface
    {
        // implement
    }
}

// 2. Implement RoutingErrorResponderInterface.
class YourRoutingErrorResponder implements N1215\Http\Router\Handler\RoutingErrorResponderInterface
{
    public function supports(RoutingException $exception): bool
    {
        // implement
    }

    public function respond(RoutingException $exception, ServerRequestInterface $request): ResponseInterface
    {
        // implement
    }
}

// 3. Configure to inject them into RoutingHandler.
$routingHandler = new N1215\Http\Router\Handler\RoutingHandler(
    new YourRouter(),
    new YourNotFoundErrorResponder(),
    new YourMethodNotAllowedErrorResponder()
);

// 4. Use RoutingHandler as an implementation of PSR-15 server request handler.
/** @var \Psr\Http\Message\ServerRequestInterface $request */
/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $routingHandler->handle($request);

Implementation examples

Class diagrams

RouterInterface

router, (*4)

RoutingException and RoutingErrorResponderInterface

routing-error, (*5)

RoutingHandler

routing-handler, (*6)

The Versions

21/02 2018

dev-master

9999999-dev https://github.com/n1215/http-router

A PSR-7 / PSR-15 compatible router interface and a PSR-15 server request handler implementation for routing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar n1215

psr-7 router psr-15

21/02 2018

v1.0.0

1.0.0.0 https://github.com/n1215/http-router

A PSR-7 / PSR-15 compatible router interface and a PSR-15 server request handler implementation for routing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar n1215

psr-7 router psr-15

07/12 2017

v0.5.0

0.5.0.0 https://github.com/n1215/http-router

A PSR-7 compatible router interface and a PSR-15 RequestHandler implementation for routing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar n1215

psr-7 router psr-15

06/12 2017

v0.4.0

0.4.0.0 https://github.com/n1215/http-router

A PSR-7 compatible router interface and a PSR-15 RequestHandler implementation for routing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar n1215

psr-7 router psr-15

04/12 2017

v0.3.0

0.3.0.0 https://github.com/n1215/http-router

PSR-7 / PSR-15 HTTP router interface.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar n1215

psr-7 router psr-15

02/12 2017

v0.2.0

0.2.0.0 https://github.com/n1215/http-router

PSR-7 / PSR-15 HTTP router interface.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar n1215

psr-7 router psr-15

02/12 2017

v0.1.0

0.1.0.0 https://github.com/n1215/http-router

PSR-7 / PSR-15 HTTP router interface

  Sources   Download

MIT

The Requires

 

by Avatar n1215

psr-7 router psr-15