Normally, for a Silex project, I would have top-level directories like:
- app/
- views/
- src/
- vendor/
- web/
Now, some of my classes may call $app['twig']->render(...)
and it will pull out a view from the app/views
folder.
If I extract a library to be more reusable, across multiple projects, where should I keep its view files, and how do I instruct Twig to look there?
The same question applies to graphics/stylesheets, etc which I would normally put in web/
.
Surely they have to be within vendor/my-lib
somewhere to allow Composer to cleanly install the files? Is there a common/best-practice way to do this?
Update For reference, here's what I ended up doing:
<?php
// in my \Silex\ServiceProviderInterface ...
/**
* @var \Twig_Environment $twig
*/
$twig = $app['twig'];
// Add the paths to our twig templates here
$fsLoader = new \Twig_Loader_Filesystem(array(
__DIR__.'/views/'
));
$twig->setLoader(new \Twig_Loader_Chain(array($twig->getLoader(), $fsLoader)));
Thanks.