mikeismint/fruit

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

Maintainers

Package info

github.com/mikeismint/Fruit.php

Issues

pkg:composer/mikeismint/fruit

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

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

This package is not auto-updated.

Last update: 2026-04-26 01:56:20 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