2017 © Pedro Peláez
 

library router

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

image

obullo/router

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  • Tuesday, April 24, 2018
  • by eguvenc
  • Repository
  • 1 Watchers
  • 1 Stars
  • 147 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Obullo / Router

Build Status License, (*1)

A standalone and secure Router package developed for Obullo-Pages inspired by Django Url Dispatcher., (*2)

Install

``` bash $ composer require obullo/router, (*3)


## Requirements The following versions of PHP are supported by this version. * 7.1 * 7.2 * 7.3 * 7.4 ## Testing ``` bash $ vendor/bin/phpunit

Quick start

require '../vendor/autoload.php';

use Obullo\Router\Route;
use Obullo\Router\RequestContext;
use Obullo\Router\RouteCollection;
use Obullo\Router\Router;
use Obullo\Router\Types\{
    StrType,
    IntType
};
$config = [
    'types' => [
        new IntType('<int:id>'),
        new StrType('<str:name>'),
    ]
];

Psr7 Request, (*4)

$request = Laminas\Diactoros\ServerRequestFactory::fromGlobals();
$context = new RequestContext;
$context->fromRequest($request);

Route Collection, (*5)

$collection = new RouteCollection($config);
$collection->setContext($context);
$collection->add('home', new Route('GET', '/', 'Views/default.phtml'));
$collection->add('dummy', new Route('GET', '/dummy/index/<int:id>/<str:name>', 'Views/dummy.phtml'))->scheme(['http','https']);
$collection->add('test', new Route('GET', '/test/index', 'Views/test.phtml'))
    ->host('example.com');
    ->scheme('http');
    ->middleware(App\Middleware\Dummy::class);

Route Class, (*6)

use Obullo\Router\RouteInterface;

$route = $collection->get('dummy');

if ($route instanceof RouteInterface) {
    echo $route->getHandler(); //  "App\Controller\DummyController::index"
    echo $route->getMethods()[0]; // GET
    echo $route->getPattern(); //  "/dummy/index/(?\d+)/(?\w+)/"
    echo $route->getMiddlewares()[0]; // App\Middleware\Dummy::class
}

Dispatch, (*7)

$router = new Router($collection);

if ($route = $router->matchRequest()) {
    $handler = $route->getHandler(); // Views/default.phtml
    $response = include $handler;

    if ($response instanceof Psr\Http\Message\ResponseInterface) {
        echo $response->getBody();
    }
}

dummy.phtml, (*8)

// Views/dummy.phtml
// 
use Laminas\Diactoros\Response\HtmlResponse;

return new HtmlResponse('Im a dummy view');

The Versions

24/04 2018

dev-master

9999999-dev http://router.obullo.com

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http route psr7 zend restful router django psr-15 zend-diactoros psr15 url dispatcher middleware aware stack aware

24/04 2018

1.0.4

1.0.4.0 http://router.obullo.com

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  Sources   Download

MIT

The Requires

 

The Development Requires

route psr7 restful router django psr15 url dispatcher middleware aware stack aware

17/04 2018

1.0.3

1.0.3.0 http://router.obullo.com

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  Sources   Download

MIT

The Requires

 

The Development Requires

route psr7 restful router django psr15 url dispatcher middleware aware stack aware

29/03 2018

1.0.2

1.0.2.0 http://router.obullo.com

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 route restful router django psr-15 url dispatcher

20/03 2018

1.0.1

1.0.1.0 http://router.obullo.com

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  Sources   Download

MIT

The Requires

 

middleware psr-7 route restful router django psr-15 url dispatcher

15/03 2018

1.0.0

1.0.0.0 http://router.obullo.com

Php7 standalone router inspired by the Django Url Dispatcher. Easy to use and Secure.

  Sources   Download

MIT

The Requires

 

middleware psr-7 route restful router django psr-15 url dispatcher

24/12 2017

0.0.5

0.0.5.0 http://router.obullo.com

Php lightweight router solution which works with zend-diactoros package.In addition, it supports the modern web router features like Route groups, Route middleware and Restful Routing.

  Sources   Download

MIT

The Requires

 

middleware http zend restful router zend-diactoros

23/12 2017

0.0.4

0.0.4.0 http://router.obullo.com

Php lightweight router solution which works with zend-diactoros package.In addition, it supports the modern web router features like Route groups, Route middleware and Restful Routing.

  Sources   Download

MIT

The Requires

 

middleware http zend restful router zend-diactoros

22/12 2017

0.0.3

0.0.3.0 http://router.obullo.com

Php lightweight router solution which works with zend-diactoros package.In addition, it supports the modern web router features like Route groups, Route middleware and Restful Routing.

  Sources   Download

MIT

The Requires

 

middleware http zend restful router zend-diactoros

21/12 2017

0.0.2

0.0.2.0 http://router.obullo.com

Php router that supports http middlewares and rest.

  Sources   Download

MIT

The Requires

 

middleware restful router http route

17/12 2017

0.0.1

0.0.1.0 http://router.obullo.com

Php router that supports http middlewares and rest.

  Sources   Download

MIT

The Requires

 

middleware restful router http route