I am currently including this at the top of every controller file:
$loader = new Twig_Loader_Filesystem('/templatedir/templates');
$twig = new Twig_Environment($loader, array('debug' => true));
$twig->addExtension(new Twig_Extension_Debug());
I find that placing this in every single file a bit redundant. Will there be any issues with placing this code in an external file and including it with a require_once
command?
The render
statement which follows in each controller file would make use of the $twig variable being included from the external file. I am a bit uncomfortable with accessing a variable from another file but am wondering if my concerns are justified.