I wonder if it is optimal to use a template engine with Cakephp 2.x like Symfony2 does. I have read that there are several template engines like Twig and Smarty.
Asked
Active
Viewed 2,561 times
2 Answers
1
Visit another question "Pure PHP/HTML views VS template engines views" for some insight into the templating engine vs php topic.
However, since you reference CakePHP, I would recommend against using a templating engine unless you require it. In my opinion, if you can markup a page in Twig or Smarty, you should be able to code a view page in CakePHP.
A big benefit of some templating engines is the built in caching functionality but you can get much greater flexibility by using CacheHelper.
0
I have integrate them Here is my code
function generate_reports(){ echo Configure::version(); $this->autoRender = false; include('../vendors/Twig/autoload.php'); $loader = new Twig_Loader_Filesystem('../views/reports/templates'); // $array=array('index' => 'Hello {{ name }}!'); //$loader = new Twig_Loader_Array($array); $twig = new Twig_Environment($loader); echo $twig->render('index.html', array('name' => 'Fabien')); }
I have download twig and put inside the vendors folder
then i have create folder named templates inside the views folder create file index.html this is content of index.html file --> Hello {{ name }}!

Senanayaka
- 309
- 6
- 18