Sometimes you may wish to use Aura as a micro-framework. It’s also possible to assigning anonymous function to controller:

<?php
$map->add("read", "/blog/read/{:id}{:format}", [
    "params" => [
        "id" => "(\d+)",
        "format" => "(\..+)?",
    ],
    "values" => [
        "controller" => function ($args) {
            $id = (int) $args["id"];
            return "Reading blog ID {$id}";
        },
        "format" => ".html",
    ],
));

When you are using Aura.Router as a micro-framework, the dispatcher will look something similar to the one below:

<?php
$params = $route->values;
$controller = $params["controller"];
unset($params["controller"]);
echo $controller($params);

Via Web Routing in PHP with Aura.Router. The Aura project for PHP 5.4 codebase is https://github.com/auraphp.

Subscribe and get latest updates by email

Enter your email address:

Delivered by FeedBurner

blog comments powered by Disqus