Using Template Engine
By default, Yii uses PHP as its default template engine language , however, you can configure Yii to support other rendering engines in an extended manner, such as Twig or Smarty. (Recommended learning: PHP programming from entry to proficiency)
The component view is used to render the view. You can reconfigure the behavior of this component to add a custom template engine.[ 'components' => [ 'view' => [ 'class' => 'yii\web\View', 'renderers' => [ 'tpl' => [ 'class' => 'yii\smarty\ViewRenderer', //'cachePath' => '@runtime/Smarty/cache', ], 'twig' => [ 'class' => 'yii\twig\ViewRenderer', 'cachePath' => '@runtime/Twig/cache', // Array of twig options: 'options' => [ 'auto_reload' => true, ], 'globals' => ['html' => '\yii\helpers\Html'], 'uses' => ['yii\bootstrap'], ], // ... ], ], ],]
"yiisoft/yii2-smarty": "*", "yiisoft/yii2-twig": "*",
The above is the detailed content of Does php use the yii template engine?. For more information, please follow other related articles on the PHP Chinese website!