PHPackages                             markup/twig-extension-proxy-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. markup/twig-extension-proxy-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

markup/twig-extension-proxy-bundle
==================================

A Symfony bundle that can provide lazy access to simpler, more common kinds of registered Twig extensions.

0.1.1(8y ago)040.1kMITPHPPHP &gt;=7.1CI failing

Since Sep 15Pushed 6y ago3 watchersCompare

[ Source](https://github.com/usemarkup/TwigExtensionProxyBundle)[ Packagist](https://packagist.org/packages/markup/twig-extension-proxy-bundle)[ RSS](/packages/markup-twig-extension-proxy-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (3)Used By (0)

TwigExtensionProxyBundle
========================

[](#twigextensionproxybundle)

A Symfony bundle that can provide lazy access to simpler, more common kinds of registered Twig extensions.

[![Build Status](https://camo.githubusercontent.com/e4abe0f52fcac6074e63152d5d9b9339707f618c60df2a3a06e487d5378b2a34/68747470733a2f2f6170692e7472617669732d63692e6f72672f7573656d61726b75702f54776967457874656e73696f6e50726f787942756e646c652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/usemarkup/TwigExtensionProxyBundle)

Why this bundle?
----------------

[](#why-this-bundle)

In a typical application using Twig, all extension services need to be instantiated to be added to a Twig environment even if a small minority of extensions will actually be used in any given execution. In a large application, the number of Twig extensions instantiated in this way can become excessive, causing mushrooming memory usage and slowdowns.

For Twig extensions that only declare functions, filters and tests into the Twig environment, this bundle provides a mechanism by which these extensions can be used lazily within a Symfony-based application.

How to use
----------

[](#how-to-use)

Typically, a Twig extension will be declared into an application using a service definition such as the following:

```
my_extension:
    class: MyBundle\MyExtension
    arguments:
        - '@my_heavy_dependency'
    tags:
        - { name: twig.extension }
```

By default, Symfony's TwigBundle will then ensure that `my_extension` will be added to the `twig` environment service.

As long as the `my_extension` extension adheres to the following rules:

1. the extension must only declare functions, filters and tests, and must instantiate them independently of any injected dependencies
2. the options for the functions, filters and tests must themselves not be dependent on injected dependencies

then it can be declared as a proxied extension instead.

The same functional effect as above can be achieved by the following declaration:

```
my_extension:
    class: MyBundle\MyExtension
    arguments:
        - '@my_heavy_dependency'
    tags:
        - { name: twig.proxied_extension }
```

With this example, any functions, filters or tests will still be declared into the `twig` environment, but the extension object itself will only be instantiated (and therefore, `my_heavy_dependency` will itself only be instantiated) once one of these Twig functors are actually *used*.

### Grouped proxies

[](#grouped-proxies)

In cases where it is useful for Twig extensions to be arranged into groups of proxies (in order to sandbox certain extensions to particular areas of an application), extension services can be tagged with the optional "groups" option. The default group is "default", so to declare additional groups on top of this there should be a comma-separated list in the tag declaration.

The following is the above extension service declaration but declaring in addition a group named "custom":

```
my_extension:
    class: MyBundle\MyExtension
    arguments:
        - '@my_heavy_dependency'
    tags:
        - { name: twig.proxied_extension, groups: "default, custom" }
```

This custom proxy extension can then be accessed with the service ID `markup_twig_extension_proxy.proxy.custom`. Typically this would then be added to a manually-declared Twig environment.

### Proxying third-party extensions

[](#proxying-third-party-extensions)

With the bundle configuration:

```
markup_twig_extension_proxy:
    proxify_tagged_extensions: true
```

an application will opt into converting any service tagged `twig.extension` into a proxied extension instead (if the extension is compatible, otherwise it will be included in the normal manner).

If you are using a version of Symfony prior to Symfony 3.2, you may need to list this bundle right near the top of your Symfony app kernel in order to convert other extensions. (The compiler pass that achieves this has a priority of 100.)

### Known issues

[](#known-issues)

Named arguments are not supported at the current time - unfortunately these are only caught at template compilation time not application compilation time, so please watch out for that!

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~19 days

Total

2

Last Release

3191d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/baa6c222b01edf945aa4e5e362583bac91f303c2a620d8774a9a5a742ade8e07?d=identicon)[gsdev](/maintainers/gsdev)

![](https://www.gravatar.com/avatar/8c89b3982be4e6cd23e749f617e809147f98aca5f45bf24c3b5195598a4c4bfd?d=identicon)[calumbrodie](/maintainers/calumbrodie)

![](https://www.gravatar.com/avatar/67cf8ed88be79605642722cbc5902206c2e51adf755f70cfff04b2c7e5abc9ce?d=identicon)[shieldo](/maintainers/shieldo)

---

Top Contributors

[![JJuszczyk](https://avatars.githubusercontent.com/u/33802769?v=4)](https://github.com/JJuszczyk "JJuszczyk (4 commits)")[![shieldo](https://avatars.githubusercontent.com/u/97280?v=4)](https://github.com/shieldo "shieldo (4 commits)")[![gsdevme](https://avatars.githubusercontent.com/u/319498?v=4)](https://github.com/gsdevme "gsdevme (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/markup-twig-extension-proxy-bundle/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

1682.8k1](/packages/symfony-ux-toolkit)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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