Question

Is it possible to use Twig in Silex from Symfony2 project instead from the standalone bundle?

I already have Symfony integrated as submodule, so is it still necessary to use Twig alongside symfony in the vendor dir?

That would save me one submodule, i mean its no problem thou, i am just curious.

It would be great if i just would have to change the *twig.class_path* to some dir in symfony.

$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path'       => __DIR__.'/../views',
'twig.class_path' => __DIR__.'/../vendor/twig/lib',
));

I am a bit lost in symfony, there is some Twig in Bridges and some in Bundle, but first i need to know if its possible at all.

Was it helpful?

Solution

No, that is not possible.

There are following libraries in existence:

  • Twig - a standalone template engine for PHP.
  • TwigServiceProvider - integration between twig and silex, this is included with silex.
  • TwigBridge - a Symfony2 bridge which adds useful features to twig, allowing tighter integration with Symfony2
  • TwigBundle - a Symfony2 core bundle that provides integration between Symfony2 and twig, depends on the TwigBridge

As you can see, twig is not included with the Symfony2 core. It is an external dependency, that you have to tie in to Symfony2, and you also have to tie into silex.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top