TomBZombie/Dice — pull request #5 by kenjis (2014-01-17 15:06:54+00:00)
Title: Fix Composer Autoloader can't find class

I got an error below:

~~~
Class twig_loader_filesystem does not exist
~~~

The true class name is `Twig_Loader_Filesystem` and located in `vendor/twig/twig/lib/Twig/Loader/Filesystem.php`.

My code is below:

~~~php
$rule1 = new \DiceRule;
$rule1->instanceOf = 'Twig_Loader_Filesystem';
$rule1->constructParams = [__DIR__ . '/../app/views'];
$container->addRule('$MyTwig_Loader_Filesystem', $rule1);

$rule2 = new \DiceRule;
$rule2->shared = true;
$rule2->constructParams = [['cache' => __DIR__ . '/../cache']];
$rule2->substitutions['Twig_LoaderInterface'] = new \DiceInstance('$MyTwig_Loader_Filesystem');
$container->addRule('Twig_Environment', $rule2);
~~~