{
    "href": "/post/2012/06/18/aura-router-can-also-be-used-as-a-micro-framework-dispatcher/",
    "relId": "2012/06/18/aura-router-can-also-be-used-as-a-micro-framework-dispatcher",
    "title": "Aura.Router can also be used as a micro-framework dispatcher!",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/aura/",
            "relId": "aura",
            "title": "Aura",
            "author": null,
            "created": "2020-09-14 21:51:57 UTC",
            "updated": [
                "2020-09-14 21:51:57 UTC"
            ],
            "markup": "markdown"
        },
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/programming/",
            "relId": "programming",
            "title": "Programming",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        }
    ],
    "created": "2012-06-18 14:23:13 UTC",
    "updated": [
        "2012-06-18 14:23:13 UTC"
    ],
    "html": "<blockquote>\n<p>Sometimes you may wish to use Aura as a micro-framework. It\u00e2\u0080\u0099s also possible to assigning anonymous function to controller:</p>\n<pre><code>&lt;?php\n$map-&gt;add(\"read\", \"/blog/read/{:id}{:format}\", [\n    \"params\" =&gt; [\n        \"id\" =&gt; \"(d+)\",\n        \"format\" =&gt; \"(..+)?\",\n    ],\n    \"values\" =&gt; [\n        \"controller\" =&gt; function ($args) {\n            $id = (int) $args[\"id\"];\n            return \"Reading blog ID {$id}\";\n        },\n        \"format\" =&gt; \".html\",\n    ],\n));</code></pre>\n<p>When you are using Aura.Router as a micro-framework, the dispatcher will look something similar to the one below:</p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php\n$params = $route-&gt;values;\n$controller = $params[\"controller\"];\nunset($params[\"controller\"]);\necho $controller($params);</pre>\n</blockquote>\n<p>Via <em><a href=\"http://phpmaster.com/web-routing-in-php-with-aura-router/\">phpmaster | Web Routing in PHP with Aura.Router</a></em>. The Aura project for PHP 5.4 codebase is <a href=\"https://github.com/auraphp\">here</a>.</p>\n"
}
