{
    "href": "/post/2015/05/19/radar-a-psr-7-action-domain-responder-framework/",
    "relId": "2015/05/19/radar-a-psr-7-action-domain-responder-framework",
    "title": "Radar: A PSR-7 Action-Domain-Responder Framework",
    "author": "pmjones",
    "markup": "html",
    "tags": [
        {
            "href": "/tag/patterns/",
            "relId": "patterns",
            "title": "Patterns",
            "author": null,
            "created": null,
            "updated": [],
            "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"
        },
        {
            "href": "/tag/radar/",
            "relId": "radar",
            "title": "Radar",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        }
    ],
    "created": "2015-05-19 15:00:58 UTC",
    "updated": [
        "2015-05-19 15:00:58 UTC"
    ],
    "html": "<p>Radar is a <a href=\"http://www.php-fig.org/psr/psr-7/\">PSR-7</a> compliant <a href=\"http://pmjones.io/adr\">Action-Domain-Responder</a> (ADR) system. While it may look like a micro-framework, it is more like a wrapper around the real core of your application domain. Its architecture makes it an excellent complement to Domain Driven Design.</p>\n<hr>\n<p>Radar is superficially similar to a micro-framework. It has a routing system to point URLs to actions, a filter-style middleware system to modify the incoming HTTP request and outgoing HTTP response, and a dependency injection container and configuration system to wire everything together.</p>\n<p>However, with Radar, you don\u2019t specify \u201ccontrollers\u201d or \u201cclosures\u201d for your routes. Instead, you specify up to three callables per route, all of which are optional:</p>\n<ol>\n<li>\n<p>A <em>Domain</em> callable to be invoked with the user input. (If you don\u2019t specify a Domain callable, the <em>Responder</em> will be invoked directly; this is unusual but sometimes convenient.)</p>\n</li>\n<li>\n<p>An <em>Input</em> callable to extract user input from the incoming HTTP <em>ServerRequest</em>. The default Radar <em>Input</em> callable will naively merge the route path attributes (path-info parameters), the query parameters (<code>$_GET</code>), the parsed body parameters (<code>$_POST</code>), and the uploaded files array (<code>$_FILES</code>) into a single associative array of user input.</p>\n</li>\n<li>\n<p>A <em>Responder</em> callable to convert the <em>Domain</em> output to an HTTP response. The default Radar <em>Responder</em> expects a <a href=\"https://github.com/auraphp/Aura.Payload\"><em>Payload</em></a> object from the <em>Domain</em>; it delivers JSON output and sets proper HTTP status codes for a wide range of scenarios.</p>\n</li>\n</ol>\n<p>These three callables are invoked within a standardized <em>ActionHandler</em>. As a result, the Action logic in Radar is always the same for every route. The only variations are in how input is collected, how output is presented, and of course in how your core application domain operates.</p>\n<p>So, don\u2019t think of Radar as a micro-framework. Think of it more like a wrapper around the core of your real application domain. Its only purpose is to guide input from the user into the domain, and to present output from the domain back to the user.</p>\n<p>You can read the documentation for it <a href=\"https://github.com/radarphp/Radar.Project/blob/1.x/docs/index.md\">here</a>.</p>\n<hr>\n<p class=\"reddit-links\">Read the Reddit discussion about this post <a href=\"https://www.reddit.com/r/PHP/comments/36hz5y/radar_a_psr7_actiondomainresponder_framework/\">here</a>.</p>\n"
}
