简体   繁体   中英

using php template in symfony 2 instead of twig

I am trying to display a symfony template using php..However, symfony is treating my php tags as "comments"

My controller

namespace Acme\testBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class testController extends Controller
{
    public function helloAction()
    {
        //return new Response('Created product id ');

        return $this->render('AcmetestBundle:test:test.html.php');
    }
}

My template : test.html.php

<?php var_dump("Hello world");?>

My output :

<!--?php var_dump("Hello world");?-->

How can I fix this?

可能只需要将php作为模板引擎添加到您的配置文件中即可。

templating: { engines: ['twig','php'] }

any more suggestions? Enabled twig as Cerad suggested, cleared cache. Still keep getting

<!--?php var_dump("Hello world");?-->

Did you google for this?

First result for "Symfony2 PHP template": http://symfony.com/doc/2.0/cookbook/templating/PHP.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM