Подключил twig по мануалу
www.yiiframework.com/doc-2.0/guide-tutorial-templa...
Создал шаблон
views/layouts/main.twig
и вид
views/articles/articles.twig
В
config/web.php'components' => [
// ...
'view' => [
'class' => 'yii\web\View',
'renderers' => [
'twig' => [
'class' => 'yii\twig\ViewRenderer',
'cachePath' => false, //'@runtime/Twig/cache',
// Array of twig options:
'options' => [
'auto_reload' => true,
],
'globals' => ['html' => '\yii\helpers\Html'],
'uses' => ['yii\bootstrap'],
],
],
],
],
В контроллере вызываю
return $this->render('articles.twig', compact('data'));
В итоге выодится
Файл composer.json
{
"require": {
"codeception/codeception": "*",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-twig": "~2.0.0"
},
"require-dev": {
"yiisoft/yii2-gii": "^2.0"
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}