项目作者: spiral

项目描述 :
Spiral Framework: Twig Adapter
高级语言: PHP
项目地址: git://github.com/spiral/twig-bridge.git
创建时间: 2018-10-06T11:14:02Z
项目社区:https://github.com/spiral/twig-bridge

开源协议:MIT License

下载


Spiral Framework: Twig Adapter

PHP Version Require
Latest Stable Version
phpunit
psalm
Codecov
Total Downloads
type-coverage
psalm-level

Documentation | Framework Bundle

Installation

The extension requires spiral/views package.

  1. composer require spiral/twig-bridge

To enable extension modify your application by adding Spiral\Twig\Bootloader\TwigBootloader:

  1. class App extends Kernel
  2. {
  3. /*
  4. * List of components and extensions to be automatically registered
  5. * within system container on application start.
  6. */
  7. protected const LOAD = [
  8. // ...
  9. Spiral\Twig\Bootloader\TwigBootloader::class,
  10. ];
  11. }

Configuration

You can enable any custom twig extension by requesting Spiral\Twig\TwigEngine in your bootloaders:

  1. class TwigExtensionBootloader extends Bootloader
  2. {
  3. public function boot(TwigEngine $engine)
  4. {
  5. $engine->addExtension(new Extension());
  6. }
  7. }

Lazy Configuration

To configure TwigEngine on demand use functionality provided by TwigBootloader:

  1. class TwigExtensionBootloader extends Bootloader
  2. {
  3. public function boot(TwigBootloader $twig)
  4. {
  5. $twig->addExtension('container.binding');
  6. }
  7. }

Note
Following methods are available setOption, addExtension, addProcessor.

License:

MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.