Framework Skeleton: Setting STDERR Views

STDERR MVC API views are programmable application components designed to output content after exceptions were handled.

How are they set?

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:

How are they compiled?

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:

Compiler Format Description
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.

How are they displayed?

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:

$this->response->setStatus(NUMERIC_AND_STRING_CODE);

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.


Share