0

I'm trying to render a php file in symfony2.

In config.yml I'm using:

# app/config/config.yml
framework:
    # ...
    templating:    { engines: ['twig', 'php'] }

and in the Controller:

public function installAction($name) {
        $finder = new Finder();
        $finder->files()->in('../src/Admin/ModuleBundle/Modules/'.$name.'/')->directories();
        foreach ($finder as $file) {
            return $this->render($file.'/install.php');
        }}

but I got this error: Template name "../src/Admin/ModuleBundle/Modules/Module1/config/install.php" contains invalid characters.

and the content of the file:

< ?php echo "Module1 install";

what I'm doing wrong? the php file is just a simple echo

BrunoRamalho
  • 1,726
  • 3
  • 17
  • 31

1 Answers1

2
< ?php echo "Module1 install";
 ^

This space. EDIT In fact, having a look at the internals, it seems that this line:

if (false !== strpos($name, '..')) {
    throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
}

(from this file) would suggest that your path cannot have relative paths that go up a level in the directory tree.

Prisoner
  • 27,391
  • 11
  • 73
  • 102