STDERR MVC API views are programmable application components designed to output content after exceptions were handled.
Lucinda Framework lets pure static response components (css, js, images) to be handled by webserver directly (in order to maximize performance), while taking full responsibility in outputting programmable response components aka "views". In Lucinda, views can be:
<application default_format="html" ...> <paths> <views>application/views</views> ... </paths> </application> <exceptions ...> <exception class="PathNotFoundException" view="view/file" .../> ... </exceptions> <renderers> <renderer format="html" content_type="text/html" .../> ... </renderers>Above will make framework display application/views/view/file.html when PathNotFoundException is handled.
Regardless of whether or not views are set by files or output stream, before being displayed they need to be compiled of any PHP logic inside, which needs to be converted to language page is supposed to be displayed with (eg: HTML). STDERR MVC API expects this to be done by Lucinda\MVC\STDERR\ErrorRenderer instances located based on value of "class" attribute of <renderer> XML tag matching response content type..
Lucinda implements following compilers:
|HtmlRenderer||html||Compiles views in HTML format using PHP templating.|
|ViewLanguageRenderer||html||Compiles views in HTML format using ViewLanguage templating.|
|JsonRenderer||json||Compiles views in JSON format.|
Once a view is compiled and its body is saved to output stream, the only step left is to display stream back to caller along with appropriate headers. Appropriate response headers are detected based on:
HTTP status code of response is to be set by controller that handles exception (Eg: "500 Internal Server Error", if default ErrorsController is used). When Lucinda\MVC\STDERR\Controller instances need to set another status:
If only a redirection is needed:
Lucinda\MVC\STDERR\Response::redirect(URL, IS_PERMANENT=true, NO_CACHE=false);
Once everything is done, Lucinda\MVC\STDERR\FrontController calls "commit" method of Lucinda\MVC\STDERR\Response instance to finally output content back to caller.