Twig searching multiple folders for template

Hi,

is is possible to configure the Slim Twig instance to search for a template in multiple directories? I know twig itself can do this, but how would I achieve this under Slim?

Thanks for any insights.

If you’re using Twig-View, then you can pass in an array of paths as the first parameter to the constructor:

    $paths = [
        '/path-one/to/templates',
        '/path-two/to/templates',
    ];
    $view = new \Slim\Views\Twig($paths, [
        'cache' => 'path/to/cache'
    ]);
1 Like

Awesome, thank you for your quick reply.