Using template engines

Using template engines

By default, Yii uses PHP as its template language, but you can configure Yii to support other rendering engines, such as Twig or Smarty available as extensions.

The view component is responsible for rendering views. You can add a custom template engine by reconfiguring this component's behavior:

[
    'components' => [
        'view' => [
            'class' => 'yii\web\View',
            'renderers' => [
                'tpl' => [
                    'class' => 'yii\smarty\ViewRenderer',
                    //'cachePath' => '@runtime/Smarty/cache',
                ],
                'twig' => [
                    'class' => 'yii\twig\ViewRenderer',
                    'cachePath' => '@runtime/Twig