Documentation/Templates/Template engine TWIG

Twig Templating Engine

The Twig templating engine is quite well-known in its field and is used by default in the Symfony framework.
It can be used as a replacement for the standard templates in the HLEB2 framework.


#Integrating TWIG

Using Composer:

$composer require "twig/twig:^3.0"


#Using TWIG

When assigning a template in the view() function, you need to specify the .twig extension for Twig templates.
The parameters from this function will be passed as variables to the Twig template in a similar manner.

The framework configuration has several settings applicable to the Twig templating engine, specifically in the /config/common.php file:

twig.options - contains a list of settings similar to those in the Twig documentation for configuring the templating engine.

twig.cache.inverted - excludes the specified directories from caching, otherwise (depending on whether caching is enabled) it includes them.


The Twig templating engine is distributed under the BSD 3-Clause license, which imposes certain restrictions on its usage.

Cached Templates Console Commands

Page translated: chatgpt 4-o
Back to top