Rola
Rola

Reputation: 195

Symfony 4 - Not rendering Twig Template

When trying to render a Twig Template within a Symfony 4 project I'm getting an error. I don't know which is the problem. This is the code generating the error:

return $this->render('templates/imagenes/index.html.twig');

And this is the error I'm getting:

LogicException You can not use the "render" method if the Templating Component or the Twig Bundle are not available.

Should I install Twig via composer apart Symfony itself?

Upvotes: 4

Views: 6084

Answers (4)

jagdish
jagdish

Reputation: 1

A guy named Simon Wald-burger mentioned in the lesson's comments that installing "debug" fixed the issue (it fixed it for me). The instruction was in the next lesson.

composer require debug --dev

iiirxs is also correct, to output dump in twig file, do

{{ dump(variable) }}

Upvotes: 0

viveka
viveka

Reputation: 193

 return $this->render('templates/imagenes/index.html.twig');

Create the project using this command

composer create-project symfony/skeleton-website project_name

No need to install twig,etc

Upvotes: 0

Craig Rayner
Craig Rayner

Reputation: 463

and you should not need the templates directory, so just 'imagenes/index.html.twig'

Upvotes: 1

Rola
Rola

Reputation: 195

Thanks @gogaz Installing twig did the trick.

composer require twig

Upvotes: 7

Related Questions