2017 © Pedro Peláez
 

library routing

PHP hyper ultra simple and mega fast route => callback mapper

image

sphido/routing

PHP hyper ultra simple and mega fast route => callback mapper

  • Saturday, June 4, 2016
  • by OzzyCzech
  • Repository
  • 2 Watchers
  • 5 Stars
  • 2,758 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Sphido / Routing

Ultra simple and fast (only 5 functions!!!) route => callback mapper, (*1)

Handlers

// map against all types of requests
/route/map('/', function() {});

// map handler against method(s) + route
/route/map('GET', '/', function() {});
/route/map(['GET', 'POST'], '/account/new', function() {});

// map handler against a route(s)
/route/map(['/kontakt', '/contact'], function () {});

// map handler against everything
/route/map(function () {});

Error Handlers

// map handler against error codes, first argument is the error code
/route/map(404, function ($code) {});
/route/map([400, 401, 403, 404], function ($code) {});
/route/map(500, function ($code) {});

Route Parameters

// if you have a symbols in any route
/route/map('GET', '/users/<id>', function ($params) {
  $id = $params['id'];
});

// attach regex rules to your route 
/route/map('GET', '/users/<id:[0-9]+>', function ($params) {
  $id = $params['id'];
});

// language selection in route
/route/map('GET', '/<lang:[a-z]{2}>/page', function ($params) {
  $lang = $params['lang'];
});

Dispatch

/app/dispatch(); // process request and dispatch results

or with some params, (*2)

/route/map('/', function($config) {});
/app/dispatch($config = new Config);

or as your app object, (*3)

class app {
  function __invoke($method, $path, $me) {
    // handle $path/$method as you need
  }
  function __destruct() {
    /app/dispatch($this);
  }
}
/route/map(new app);

Possible changes

  • default values <param=cz:[a-z]{2}> ???
  • case sensitivity vs. insensitivity ??? currently is case sensitive
  • optional parametter (<param>)? ???
  • optional strings <name>(.html)? ????

The Versions

04/06 2016

dev-master

9999999-dev http://www.sphido.org

PHP hyper ultra simple and mega fast route => callback mapper

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.0

 

The Development Requires

api rest mapper routing router

04/06 2016

v0.1.0

0.1.0.0 http://www.sphido.org

PHP hyper ultra simple and mega fast route => callback mapper

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.0

 

The Development Requires

api rest mapper routing router

22/01 2015

v0.0.1

0.0.1.0 http://www.sphido.org

PHP hyper ultra simple and mega fast route => callback mapper

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.5.6

 

The Development Requires

api rest mapper routing router