You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".
class RecordsController extends AbstractController
{
/**
* @Route("/", name="single_page")
* @return Response
*/
public function singlePageAction()
{
return $this->render('single_page.html.twig', []);
}
}
Symfony 4 - Not rendering Twig Template
Same as for this guy but accepted answer does not help.
Tried also
composer require debug --dev
then got error
[InvalidArgumentException]
Could not find package debug.
Did you mean one of these?
symfony/debug
tracy/tracy
maximebf/debugbar
cakephp/debug_kit
symfony/debug-pack
so installed symfony/debug. Which does not make any sense but I did. Of course it did not fix the problem.
Here is how composer.json now looks:
{
"require": {
"symfony/maker-bundle": "^1.13",
"twig/twig": "~2.10",
"symfony/twig-bundle": "^4.3"
},
"require-dev": {
"symfony/debug": "^4.3"
}
}
I have installed twig 2 because otherwise could not install twig-bundle - was gettig error.
How to get rid of this error and show the template?
Update: Noticed that my application has 2 composer.json files. One in root, another in myapp folder. Guess this is why after install it does not see because it is installed in that root directory. But now I am too angry and tired already to check, will need to do that later.