A Typical Request and Response

    While a li3 application can be configured a number of different ways, the safest is by pointing your web server to the folder inside the application. It can be pointed at the root directory of the application, but either way, the request is forwarded on until /app/webroot/index.php handles it.

    This directory index file does two things: first, it loads up li3’s main bootstrap file (and any related bootstrap files therein). Second, it instantiates the dispatcher, and hands its run() method a new object. The Request object aggregates all the GET / POST / environment data, and is the canonical source of any of that information throughout the life of the request.

    Once Dispatcher has the request, it asks the router to process it. This processing basically matches the request against each configured route, in the order they were defined. Once a match is found, the Router returns parameter information necessary to find a controller class, and dispatch a method call against it.

    Each controller action contains a set of business logic to build a facet or interface in your application. It may interact with models or other classes to fetch, validate, sanitize, and process the data.

    Once the data is ready for the view layer, the action hands it off either through , or by returning an associative array. That data is passed, along with information about the response type, to the Media class.

    The Media class facilitates content-type mapping (mapping between content-types and file extensions), handling static assets, and globally configuring how the framework handles output in different formats.

    Media is extremely flexible, however, and the response could result in JSON serialization, XML formatting, or writing out the contents of an audio file to the output buffer. Content type mapping is done by calling Media::type(), usually in a bootstrap file.

    Finally, the response content, along with any headers, are packed into a response class, which is passed by the controller back up to Dispatcher. The dispatcher returns the Response object to index.php, where it is echoed to the output buffer.

    This echo writes the headers, and performs a buffered output of whatever content was returned from the Media class.