PHPackages                             sympress/twig-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. sympress/twig-bundle

ActiveLibrary[Templating &amp; Views](/categories/templating)

sympress/twig-bundle
====================

Twig integration bundle for SymPress with Symfony TwigBundle feature parity.

1.0.1(1mo ago)00GPL-2.0-or-laterPHPPHP ^8.5CI passing

Since Jun 14Pushed 2w agoCompare

[ Source](https://github.com/SymPress/twig-bundle)[ Packagist](https://packagist.org/packages/sympress/twig-bundle)[ RSS](/packages/sympress-twig-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

SymPress TwigBundle
===================

[](#sympress-twigbundle)

[![Checks](https://camo.githubusercontent.com/2eabbad40ef2848a9331d1a80578bc12cbaf49efc150eef2afafb5ba693a7ebe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f53796d50726573732f747769672d62756e646c652f71612e796d6c3f6272616e63683d6d61696e266c6162656c3d636865636b73)](https://github.com/SymPress/twig-bundle/actions/workflows/qa.yml) [![Release](https://camo.githubusercontent.com/21cb00d90e3c7a868193aed492ae894b1c4470087ed1929bfe365ed837706b8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f53796d50726573732f747769672d62756e646c653f6c6162656c3d72656c65617365)](https://github.com/SymPress/twig-bundle/releases) [![PHP](https://camo.githubusercontent.com/6d4dfae4b14c707f7bae2f58cf52b36a2627449de6c108bd61a49f3e8aff9f01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f73796d70726573732f747769672d62756e646c652f7068702e7376673f6c6162656c3d706870)](https://packagist.org/packages/sympress/twig-bundle) [![Downloads](https://camo.githubusercontent.com/31c73cc9358a17ffcbdc1b00f33e761d4c7407f37f8ca5c32b2d0141e4d6c6b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73796d70726573732f747769672d62756e646c652e7376673f6c6162656c3d646f776e6c6f616473)](https://packagist.org/packages/sympress/twig-bundle/stats) [![License: GPL-2.0-or-later](https://camo.githubusercontent.com/26f8b6541ea045cc1dbc2267208158b5a7ebbf5cf437c4b486d80fee9386f77e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c2d2d322e302d2d6f722d2d6c617465722d626c75652e737667)](LICENSE) [![Security Policy](https://camo.githubusercontent.com/7a0ecd25391c2821401e28d753557f53c5fe267b349b8b4032bb4ca1ef462ee7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73656375726974792d706f6c6963792d3265613434662e737667)](SECURITY.md)

`sympress/twig-bundle` integrates Twig into the SymPress kernel while delegating the core feature set to Symfony's `symfony/twig-bundle`.

Installation
------------

[](#installation)

```
composer require sympress/twig-bundle
```

The bundle is discovered by the SymPress kernel through the package metadata in `composer.json`. It requires PHP 8.5, SymPress Kernel, SymPress FrameworkBundle, Symfony TwigBundle, and Twig 3.

Features
--------

[](#features)

- Symfony TwigBundle compiler passes and service definitions
- Symfony Twig configuration under the `twig` extension alias
- Template lookup in project `templates/`, bundle `Resources/views`, and bundle `templates`
- Autoconfiguration for Twig extensions, loaders, runtimes, and Twig attributes
- Injectable `TemplateRendererInterface`
- Optional SymPress API for service-backed Twig globals

Configuration
-------------

[](#configuration)

Twig configuration uses Symfony's standard `twig` extension alias:

```
twig:
    default_path: '%kernel.project_dir%/templates'
    strict_variables: '%kernel.debug%'
```

The bundle loads its own service wiring from `Resources/config/services.yaml` and keeps Symfony TwigBundle service definitions intact. Project services can keep using normal Twig extension, loader, runtime, and attribute APIs.

Twig Extensions
---------------

[](#twig-extensions)

Services implementing Twig's extension, loader, or runtime interfaces are autoconfigured the same way as in Symfony:

```
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

final class ShopTwigExtension extends AbstractExtension
{
    public function getFunctions(): array
    {
        return [
            new TwigFunction('shop_name', fn (): string => 'SymPress'),
        ];
    }
}
```

Twig attributes from `twig/twig` are supported as well:

```
use Twig\Attribute\AsTwigFunction;

final class ShopTwigRuntime
{
    #[AsTwigFunction('shop_name')]
    public function shopName(): string
    {
        return 'SymPress';
    }
}
```

Twig Globals
------------

[](#twig-globals)

Services can provide several globals by implementing `GlobalProviderInterface`:

```
use SymPress\TwigBundle\Extension\GlobalProviderInterface;

final class AppGlobals implements GlobalProviderInterface
{
    public function getGlobals(): iterable
    {
        return [
            'app_name' => 'SymPress',
        ];
    }
}
```

For one service-backed global, tag a service class with `AsTwigGlobal`:

```
use SymPress\TwigBundle\Attribute\AsTwigGlobal;

#[AsTwigGlobal('current_account')]
final class CurrentAccount
{
}
```

Rendering
---------

[](#rendering)

Inject `SymPress\TwigBundle\Renderer\TemplateRendererInterface` when a service needs view rendering without extending a controller base class.

```
use SymPress\TwigBundle\Renderer\TemplateRendererInterface;

final readonly class PageRenderer
{
    public function __construct(
        private TemplateRendererInterface $templates,
    ) {
    }

    public function render(): string
    {
        return $this->templates->render('page.html.twig', [
            'title' => 'Hello SymPress',
        ]);
    }
}
```

Controllers can use `TwigResponseTrait` when they need a Symfony `Response` from a Twig template without coupling to a concrete renderer implementation.

Quality Checks
--------------

[](#quality-checks)

```
composer qa
```

The QA command runs PHPCS, PHPStan, and PHPUnit with the package configuration used by the GitHub Actions workflow.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

41d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/53712359?v=4)[Brian Schäffner](/maintainers/brianvarskonst)[@brianvarskonst](https://github.com/brianvarskonst)

---

Top Contributors

[![brianvarskonst](https://avatars.githubusercontent.com/u/53712359?v=4)](https://github.com/brianvarskonst "brianvarskonst (10 commits)")

---

Tags

composerdependency-injectionphpsymfonytemplatestemplatingtemplating-enginetwigtwig-bundlewordpress

### Embed Badge

![Health badge](/badges/sympress-twig-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sympress-twig-bundle/health.svg)](https://phpackages.com/packages/sympress-twig-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M404](/packages/easycorp-easyadmin-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M607](/packages/shopware-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k64](/packages/open-dxp-opendxp)[chameleon-system/chameleon-base

The Chameleon System core.

1028.7k5](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
