Skip to content

View Service

The view service uses the Phalcon View Component

Configurations

VIEW_MINIFY=false

View Service Provider

PROVIDER_VIEW=\Zemit\Provider\View\ServiceProvider

View Configurations Object

<?php
new Config([
    'providers' => [
        \Zemit\Provider\View\ServiceProvider::class => Env::get('PROVIDER_VIEW', \Zemit\Provider\View\ServiceProvider::class),
    ],
    'view' => [
        'minify' => Env::get('VIEW_MINIFY', false),
        'engines' => Env::get('VIEW_ENGINES', [
            '.phtml' => \Phalcon\Mvc\View\Engine\Php::class,
            '.volt' => \Phalcon\Mvc\View\Engine\Volt::class,
//            '.mhtml' => \Phalcon\Mvc\View\Engine\Mustache::class,
//            '.twig' => \Phalcon\Mvc\View\Engine\Twig::class,
//            '.tpl' => \Phalcon\Mvc\View\Engine\Smarty::class
        ]),
    ],
]);

View Service (view)

View Service Provider

View Service Provider (view): \Zemit\Provider\View\ServiceProvider

<?php
// Retrieving the service from an Injectable
$view = $this->view;

// Retrieving the service from the DI
$view = $this->di->get('view');

// Retrieving the service from the getDI()
$view = $this->getDI()->get('view');

// Retrieving the service from anywhere
$view = Di::getDefault()->get('view');