windy/lazyrouter

Translates request URIs into method calls.

dev-master 2014-04-21 21:58 UTC

This package is not auto-updated.

Last update: 2024-04-27 13:04:06 UTC


README

Translate requests into method calls.

Composer

{
    "require": {
        "windy/lazyrouter": "dev-master"
    }
}

Example

Note: Make sure you redirect all requests to a single index.php.

An example index.php

<?php
require_once 'Router.php';
use lazyrouter\Router;

$router = new Router();
$router->route(function() {}, function() {});

A request such as 'hello/world' would be interpreted as.

require_once 'controllers/hello.php';
$controller = new hello();
$controller->world();

Namespaces are permitted as well. Something like 'foo/bar/baz' would be interpreted as.

require_once 'controllers/bar.php';
$controller = new foo\bar();
$controller->baz();