View

Configuration & usage

Views represent the user interface of your application. Views are often HTML files with embedded PHP code that perform tasks related solely to the presentation of the data. Views format the content that you need to send back to the user/web browser that initiated the request.

Phalcon\Mvc\View and Phalcon\Mvc\View\Simple are responsible for the managing the view layer of your MVC application.

Configurations

You can choose between many engines: phtml, volt, mhtml, twig, tpl

VIEW_MINIFY=false
VIEW_ENGINES=phtml,volt,mhtml,twig,tpl
# Local Storage
FILE_SYSTEM_DRIVER=local

# Volt Settings
VOLT_AUTOESCAPE=false
VOLT_ALWAYS=false
VOLT_EXTENSION=.php
VOLT_SEPARATOR=%%
VOLT_PATH=./
VOLT_PREFIX=
VOLT_STAT=true

Usage

// if the class is aware of injections
$view = $this->view;

// if the container is present
$view = $this->di->get('view');

// from outside
$view = Di::getDefault()->get('view');

Sources

Last updated