2017 © Pedro Peláez
 

library router

Lightweight and performant router inspired by laravel's, and phalcon's router.

image

sasa-b/router

Lightweight and performant router inspired by laravel's, and phalcon's router.

  • Monday, October 9, 2017
  • by sasa-b
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Router

Lightweight router inspired by Laravel's and Phalcon's router., (*1)


Usage examples

$router = new \Foundation\Routing\Router();

$r->get('/foo', function () {
    echo 'Hello foo!';
});

// here we are utilising cache for performance, if the cache file was not found 
// routes will be registered and the cache file recreated
$router->cache(function (\Foundation\Routing\Router $r) {
    // if you want to collect routes from a file
    // you can set the path to the routes file as a paramater to collectRoutes() method
    // or via setRoutesPath() method
    $r->collectRoutes();

    // you can both collect routes and add them one by one, they will be merged
    $r->get('/foo/{bar}', [
        'controller' => 'FooController',
        'action' => 'index',
    ]);

    $r->post('/foo/{bar}', 'FooController::store');
});

try {
    // Adding event listeners
    $router->addEventListener('before_match', function(\Foundation\Routing\Router $router) {
        echo "before match";
    });

    $router->addEventListener('after_match', function(\Foundation\Routing\Router $router) {
        echo "after match";
    });

    $dispatcher = $router->catch();

    $dispatcher->dispatch();

} catch (\Foundation\Routing\Exceptions\NotFoundException $e) {
    echo $e->getCode() . " - Page not found";
} catch (\Foundation\Routing\Exceptions\BadHttpMethodException $e) {
    echo $e->getCode() . " - Bad Http Method";
} 

The Versions

09/10 2017

dev-master

9999999-dev https://sasablagojevic.com

Lightweight and performant router inspired by laravel's, and phalcon's router.

  Sources   Download

MIT

The Requires

 

by Sasa Blagojevic

dispatcher routing router

09/10 2017

1.0.2

1.0.2.0 https://sasablagojevic.com

Lightweight and performant router inspired by laravel's, and phalcon's router.

  Sources   Download

MIT

The Requires

 

by Sasa Blagojevic

dispatcher routing router

09/10 2017

1.0.1

1.0.1.0 https://sasablagojevic.com

Lightweight and performant router inspired by laravel's, and phalcon's router.

  Sources   Download

MIT

The Requires

 

by Sasa Blagojevic

dispatcher routing router

07/10 2017

1.0.0

1.0.0.0 https://sasablagojevic.com

Lightweight and performant router inspired by laravel's, and phalcon's router.

  Sources   Download

MIT

The Requires

 

by Sasa Blagojevic

dispatcher routing router