https://github.com/spiral/twig-bridge
Spiral Framework: Twig Adapter
https://github.com/spiral/twig-bridge
php7 rendering spiral spiral-framework twig twig-adapter
Last synced: 5 months ago
JSON representation
Spiral Framework: Twig Adapter
- Host: GitHub
- URL: https://github.com/spiral/twig-bridge
- Owner: spiral
- License: mit
- Created: 2018-10-06T11:14:02.000Z (over 7 years ago)
- Default Branch: 2.0
- Last Pushed: 2023-01-30T08:46:28.000Z (over 3 years ago)
- Last Synced: 2025-05-30T10:51:30.269Z (about 1 year ago)
- Topics: php7, rendering, spiral, spiral-framework, twig, twig-adapter
- Language: PHP
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spiral Framework: Twig Adapter
[](https://packagist.org/packages/spiral/twig-bridge)
[](https://packagist.org/packages/spiral/twig-bridge)
[](https://github.com/spiral/twig-bridge/actions)
[](https://github.com/spiral/twig-bridge/actions)
[](https://codecov.io/gh/spiral/twig-bridge/)
[](https://packagist.org/packages/spiral/twig-bridge)
[](https://shepherd.dev/github/spiral/twig-bridge)
[](https://shepherd.dev/github/spiral/twig-bridge)
[Documentation](https://spiral.dev/docs/views-twig) | [Framework Bundle](https://github.com/spiral/framework)
## Installation
The extension requires `spiral/views` package.
```
composer require spiral/twig-bridge
```
To enable extension modify your application by adding `Spiral\Twig\Bootloader\TwigBootloader`:
```php
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,
];
}
```
## Configuration
You can enable any custom twig extension by requesting `Spiral\Twig\TwigEngine` in your bootloaders:
```php
class TwigExtensionBootloader extends Bootloader
{
public function boot(TwigEngine $engine)
{
$engine->addExtension(new Extension());
}
}
```
## Lazy Configuration
To configure TwigEngine on demand use functionality provided by `TwigBootloader`:
```php
class TwigExtensionBootloader extends Bootloader
{
public function boot(TwigBootloader $twig)
{
$twig->addExtension('container.binding');
}
}
```
> **Note**
> Following methods are available `setOption`, `addExtension`, `addProcessor`.
## License:
MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com).