Manish Basdeo
Manish Basdeo

Reputation: 6269

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?

Upvotes: 0

Views: 2752

Answers (3)

Kirill Oficerov
Kirill Oficerov

Reputation: 2300

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

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

Upvotes: 0

Cerad
Cerad

Reputation: 48893

Probably just need to add php as a template engine to your config file.

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

Upvotes: 7

Louis-Philippe Huberdeau
Louis-Philippe Huberdeau

Reputation: 5431

Did you google for this?

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

Upvotes: 0

Related Questions