0

I am trying to create a website with Symfony 2.0 and I am running into an issue where I see extend("...") ?> from <?php $this->extend("...") ?>.

The site is viewable at http://symfony.toxic-productions.com/install/web/poshpaws/hello.

The code for the controller:

<?php
    namespace Acme\HelloBundle\Controller;

    use Symfony\Bundle\FrameworkBundle\Controller\Controller;

    class HelloController extends Controller
    {
        public function indexAction($name)
        {
            //return $this->render('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));
            // render a PHP template instead
            return $this->render('AcmeHelloBundle:Hello:index.html.php', array('name' => $name));
        }
    }
?>

The code for the frontend page (index.html.php)

<html>
    <head>
        <title>Poshpaws</title>
        <?php
            $view->extend('::base.html.php');
            echo($head);
        ?>
    </head>
    <body>
        <?php echo($body); ?>
        <h1>This is just a page to say: Hello <?php echo $view->escape($name) ?>!</h1>
    </body>
</html>
3
  • It appears at the moment that the server doesn't have PHP installed or at the very least things aren't working correctly. If you view the source of the page, you will see the <?php tags which means PHP is not parsing that file at all and it is being served directly by the web server without any processing applied. Are you calling the right file? Sorry I haven't used Symfony but you appear to be calling the view directly and I don't think the controller is getting called. Commented Jun 26, 2012 at 21:31
  • PHP is most certainly installed, if you go to "toxic-productions.com" on it's own, that's full PHP. I'll check to make sure that everything is configured in the VirtualHost anyway, however. Commented Jun 26, 2012 at 21:33
  • It may be that your .htaccess file for handling all the requests is not in the right place. It should be in the web folder. Commented Jun 26, 2012 at 21:45

2 Answers 2

1

I just had the same problem. It turned out that I didn't have php templating engine enabled in my configuration file. Make sure you check the first step from this site: http://symfony.com/doc/current/cookbook/templating/PHP.html

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, Peter. The link you gave is very useful about using PHP/twig in Symfony. In this file config.yml, you have to set engines as 'twig', 'php' in order to use both or use one of them to use one template. Very thankful for the link.
0

Your .htaccess file either isn't working or isn't in the right place. Make sure it's in the web folder. If it is, then make sure your webhost allows you to override Apache settings. If it does, then run php app/console router:debug over SSH and make sure your route is properly defined. Also, you really should just set "web" as the root of your directory or you expose certain security risks needlessly.

On a side note...why PHP templates? To me, it doesn't enforce separation of concerns quite as well and they're generally harder to read (for me, anyway).

1 Comment

It's just what I'm used to when making websites. I'm also going to try a fresh install in another directory to see if it's actually SuPHP playing up again. Also, I'm hosting my own website, so everything for my domains can be overridden :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.