2017 © Pedro Peláez
 

library scabbia2-router

Scabbia2 Router Component

image

eserozvataf/scabbia2-router

Scabbia2 Router Component

  • Sunday, January 3, 2016
  • by eserozvataf
  • Repository
  • 1 Watchers
  • 5 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 14 % Grown

The README.md

Scabbia2 Router Component

This component is a simple routing dispatcher which resolves and dispatchs the routes to callbacks or controllers., (*1)

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version Documentation Status, (*2)

Usage

Creating route definitions

use Scabbia\Router\RouteCollection;

$routes = new RouteCollection();

// adding a static route
$routes->addRoute('GET', '/about', 'AboutController::IndexAction');

// adding a static route with multiple http methods
$routes->addRoute(['GET', 'POST'], '/about', 'AboutController::IndexAction');

// adding a dynamic route
$routes->addRoute('GET', '/users/profile/{id:[a-z]+}', 'UsersController::ProfileAction');

// adding a dynamic route with a routing name
$routes->addRoute('GET', '/users/posts/{id:[a-z]+}', 'UsersController::PostsAction', 'user/posts');

Saving route definitions

file_put_contents('routes.json', json_encode($routes->save()));

Loading route definitions back

$routes = json_decode(file_get_contents('routes.json'));

Dispatching a route

use Scabbia\Router\Router;

$router = new Router($routes); // initialize a new router with route definitions
$route = $router->dispatch('GET', '/about');

if ($route['status'] === Router::FOUND) {
  call_user_func($route['callback'], ...$route['parameters']);
}

Reverse Routing with names

use Scabbia\Router\Router;

$router = new Router($routes); // initialize a new router with route definitions

echo $router->path('users/posts', [ 'id' => 'eser' ]);

Contributing

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome. All contributions should be filed on the eserozvataf/scabbia2-router repository., (*3)

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub issues.
  • To support: Donate

The Versions

03/01 2016

dev-master

9999999-dev https://github.com/eserozvataf/scabbia2

Scabbia2 Router Component

  Sources   Download

Apache-2.0 BSD-3-Clause

The Requires

  • php >=5.6.0

 

The Development Requires

by Nikita Popov

routing router scabbia eserozvataf scabbia2 scabbiafw

16/09 2015

v0.1.2

0.1.2.0 http://www.scabbiafw.com/

Scabbia2 Router Component

  Sources   Download

Apache-2.0 BSD-3-Clause

The Requires

  • php >=5.6.0

 

The Development Requires

by Nikita Popov

routing router scabbia larukedi scabbia2 scabbiafw