README.md 1.1 KB
Newer Older
1 2
Twig Extension for Yii 2
========================
3

4
This extension provides a `ViewRender` that would allow you to use Twig view template engine.
5

6
To use this extension, simply add the following code in your application configuration:
7 8

```php
Alexander Makarov committed
9
return [
10 11 12 13 14 15
    //....
    'components' => [
        'view' => [
            'renderers' => [
                'twig' => [
                    'class' => 'yii\twig\ViewRenderer',
16
                    // set cachePath to false in order to disable template caching
17 18 19 20 21
                    'cachePath' => '@runtime/Twig/cache',
                    // Array of twig options:
                    'options' => [
                        'auto_reload' => true,
                    ],
22 23 24 25 26
                    // ... see ViewRenderer for more options
                ],
            ],
        ],
    ],
Alexander Makarov committed
27
];
28 29
```

30 31 32 33 34 35 36 37 38

Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
39
php composer.phar require --prefer-dist yiisoft/yii2-twig "*"
40 41 42 43 44 45 46 47 48
```

or add

```
"yiisoft/yii2-twig": "*"
```

to the require section of your composer.json.