You can access the twig loader using $ app ['twig.loader.filesystem'].
For example, put this in your controller class in the connection method
$app['twig.loader.filesystem']->addPath( $pathToTemplates );
There is also Twig_Loader_Filesystem :: prependPath ()
You can also specify a namespace for paths. To do this, simply add the namespace name as the second parameter, for example, "NAMESPACE". In this case, you can access your templates $app['twig']->render('@NAMESPACE/pathToATemplate'); Note @ is a char in front of the namespace when it is rendered.
source share