spiral/twig-bridge
Twig adapter for the Spiral Framework. Adds a Twig view engine via TwigBootloader, with support for custom extensions, options, and processors. Configure eagerly through TwigEngine or lazily through TwigBootloader. Requires spiral/views.
Documentation | Framework Bundle
The extension requires spiral/views package.
composer require spiral/twig-bridge
To enable extension modify your application by adding Spiral\Twig\Bootloader\TwigBootloader:
class App extends Kernel
{
/*
* List of components and extensions to be automatically registered
* within system container on application start.
*/
protected const LOAD = [
// ...
Spiral\Twig\Bootloader\TwigBootloader::class,
];
}
You can enable any custom twig extension by requesting Spiral\Twig\TwigEngine in your bootloaders:
class TwigExtensionBootloader extends Bootloader
{
public function boot(TwigEngine $engine)
{
$engine->addExtension(new Extension());
}
}
To configure TwigEngine on demand use functionality provided by TwigBootloader:
class TwigExtensionBootloader extends Bootloader
{
public function boot(TwigBootloader $twig)
{
$twig->addExtension('container.binding');
}
}
Note Following methods are available
setOption,addExtension,addProcessor.
MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.
How can I help you explore Laravel packages today?