README.md 1.48 KB
Newer Older
1
Yii 2.0 Public Preview - Twig View Renderer
2
===========================================
3 4 5 6 7 8 9 10 11 12 13 14 15

Thank you for choosing Yii - a high-performance component-based PHP framework.

If you are looking for a production-ready PHP framework, please use
[Yii v1.1](https://github.com/yiisoft/yii).

Yii 2.0 is still under heavy development. We may make significant changes
without prior notices. **Yii 2.0 is not ready for production use yet.**

[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2)

This is the yii2-twig extension.

16

17
Installation
18 19
------------

20 21 22 23
The prefered way to install this extension is through [composer](http://getcomposer.org/download/).

Either run
```
24
php composer.phar require yiisoft/yii2-twig "*"
25 26 27 28 29 30 31 32 33 34 35 36 37
```

or add
```
"yiisoft/yii2-twig": "*"
```
to the require section of your composer.json.


*Note: You might have to run `php composer.phar selfupdate`*


Usage & Documentation
38
---------------------
39 40

This extension has to be registered prior to usage.
Suralc committed
41
To enable this view renderer add it to the $rendereres property of your view object.
42 43 44 45 46 47 48 49 50 51

Example: 
```php
<?php
// config.php
return array(
	//....
	'components' => array(
		'view' => array(
			'class' => 'yii\base\View',
Suralc committed
52
			'renderers' => array(
53 54 55 56 57 58 59 60 61 62 63
				'twig' => array(
					'class' => 'yii\twig\ViewRenderer',
					//'cachePath' => '@runtime/Twig/cache',
					//'options' => array(), /*  Array of twig options */
				),
			),
		),
	),
);
```

64
For further instructions refer to the related section in the yii guide.