mikeismint/fruit

There is no license information available for the latest version (dev-master) of this package.

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

pkg:composer/mikeismint/fruit

dev-master 2017-04-07 21:40 UTC

This package is not auto-updated.

Last update: 2026-01-18 00:24:54 UTC


README

My first attempt at a simple PHP router. Influenced by AltoRouter

Usage

$router = new Fruit();

// map single route
$router->addRoute('GET', '/', 'Controller#Method');

// map post details page
$router->addRoute('GET', '/^posts\/id\/(?P<id>\d+)$/', 'Controller#Method');

// map multiple routes
$router->addRoutes(array(
    array('GET', '/', 'Controller#Method'),
    array('GET', '/^posts\/id\/(?P<id>\d+)$/', 'Controller#Method'),
));

Other features

  • Accepts multiple HTTP methods separated by |
  • Uses regex to match URL pattern
  • Accepts optional fourth parameter to name routes