README.md 1.03 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 22 23
                    //'cachePath' => '@runtime/Twig/cache',
                    //'options' => [], /*  Array of twig options */
                    // ... see ViewRenderer for more options
                ],
            ],
        ],
    ],
Alexander Makarov committed
24
];
25 26
```

27 28 29 30 31 32 33 34 35

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

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

Either run

```
36
php composer.phar require --prefer-dist yiisoft/yii2-twig "*"
37 38 39 40 41 42 43 44 45
```

or add

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

to the require section of your composer.json.