Symfony5 path from Controller to a twig file inside a bundle

Viewed 9

Hello I Have inside {root_dir}/src/veo/SomeBundle/Controller/SomeController.php

return $this->render('index.html.twig', array(
            "article" => $articles
 ));

As default symfony includes {root_dir}/templates/ How can I override this to {root_dir}/src/veo/SomeBundle/Resource/views/

1 Answers

I resolved this by adding namespace inside config/packages/twig.yaml

twig:
    default_path: '%kernel.project_dir%/templates'
    paths:
        "%kernel.project_dir%/src/Veo/SomeBundle/Resources/views": foo_bar
when@test:
    twig:
        strict_variables: true

and inside Controller:

return $this->render('@foo_bar/Anomalies/index.html.twig', array(
Related