PHPackages                             emanueleminotto/twig-cache-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. emanueleminotto/twig-cache-bundle

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

emanueleminotto/twig-cache-bundle
=================================

Symfony 2 Bundle for twigphp/twig-cache-extension

1.3.1(4y ago)59678.3k↓12.9%13[2 issues](https://github.com/EmanueleMinotto/TwigCacheBundle/issues)4MITPHPPHP ^7.2|^8.0CI failing

Since Jan 29Pushed 4y ago7 watchersCompare

[ Source](https://github.com/EmanueleMinotto/TwigCacheBundle)[ Packagist](https://packagist.org/packages/emanueleminotto/twig-cache-bundle)[ RSS](/packages/emanueleminotto-twig-cache-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (4)

Twig cache extension Bundle
===========================

[](#twig-cache-extension-bundle)

[![Build Status](https://camo.githubusercontent.com/39fcb01183f805466ade2cbf9129a4d9201418a79b046ab63395526c88753f48/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f456d616e75656c654d696e6f74746f2f54776967436163686542756e646c652e7376673f7374796c653d666c6174)](https://travis-ci.org/EmanueleMinotto/TwigCacheBundle)[![SensioLabs Insight](https://camo.githubusercontent.com/c94a29c0182f5e0e667fe11b75bc37f7c2c42f249060fbf088d09ba64ec77c03/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f30313062323331652d306533352d346261382d393932392d6562343865373733333162322e7376673f7374796c653d666c6174)](https://insight.sensiolabs.com/projects/010b231e-0e35-4ba8-9929-eb48e77331b2)[![Coverage Status](https://camo.githubusercontent.com/dc3b2e4c31fa538e5738db999dd86fee3464baa99e4baae7f7b02ae8dccdb4a2/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f456d616e75656c654d696e6f74746f2f54776967436163686542756e646c652e7376673f7374796c653d666c6174)](https://coveralls.io/r/EmanueleMinotto/TwigCacheBundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1d2c0b34e76feef54743f91d4a2b34b50ba5ea66630ff9605e0946bc3fe4f4b8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f456d616e75656c654d696e6f74746f2f54776967436163686542756e646c652e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/EmanueleMinotto/TwigCacheBundle/)[![Total Downloads](https://camo.githubusercontent.com/3b46372680e56a0dcf84ec72d8847dbc88c330e2dc6ada603db9c09e4c89dcec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656d616e75656c656d696e6f74746f2f747769672d63616368652d62756e646c652e7376673f7374796c653d666c6174)](https://packagist.org/packages/emanueleminotto/twig-cache-bundle)

Symfony Bundle for [twigphp/twig-cache-extension](https://github.com/twigphp/twig-cache-extension).

API: [emanueleminotto.github.io/TwigCacheBundle](http://emanueleminotto.github.io/TwigCacheBundle/)

Install bundle using Composer
-----------------------------

[](#install-bundle-using-composer)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require emanueleminotto/twig-cache-bundle
```

This command requires you to have [Composer](https://getcomposer.org/) installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

Add Bundle to AppKernel
-----------------------

[](#add-bundle-to-appkernel)

Then, enable the bundle by adding the following line in the `bundles.php`file of your project:

```
// bundles.php
return [
    // ...
    EmanueleMinotto\TwigCacheBundle\TwigCacheBundle::class => ['all' => true],
    // ...
];
```

Configure services
------------------

[](#configure-services)

This bundle allows to easily configure the caching service the extension will use for the caching. The extension by default supports instances of `Doctrine\Common\Cache\Cache` but allows you to use packages that provide a `psr/cache-implementation`.

```
# app/config/config.yml
twig_cache:
    service: cache_service # instance of Doctrine\Common\Cache\Cache or Psr\Cache\CacheItemPoolInterface
```

Configuring a PSR-6 Cache pool implementation is possible by changing the extension's default adapter class to the `PsrCacheAdapter` that is provided with the extension.

```
# parameters.yml
twig_cache.adapter.class: Twig\CacheExtension\CacheProvider\PsrCacheAdapter
```

After that, you should install a package that provides a `psr/cache-implementation`. A wide variety of implementations already can be found at: After installing an adapter with composer, it can be configured to do the caching for this bundle. The [`CacheBundle`](https://github.com/php-cache/cache-bundle) allows easy configuration by creating a Symfony service for the cache pool adapter.

```
# config.yml
cache_adapter:
    providers:
        twig_apcu:
            factory: 'cache.factory.apcu'

twig_cache:
    service: cache.provider.twig_apcu
```

Usage
-----

[](#usage)

The default strategy is the `IndexedChainingCacheStrategy` so you can use directly this code in your [Twig](http://twig.sensiolabs.org/) templates.

```
{# delegate to lifetime strategy #}
{% cache 'v1/summary' {time: 300} %}
    {# heavy lifting template stuff here, include/render other partials etc #}
{% endcache %}

{# delegate to generational strategy #}
{% cache 'v1/summary' {gen: item} %}
    {# heavy lifting template stuff here, include/render other partials etc #}
{% endcache %}
```

Readings:

- [Configuration Reference](https://github.com/EmanueleMinotto/TwigCacheBundle/tree/master/Resources/doc/configuration-reference.rst)
- [Change caching strategy](https://github.com/EmanueleMinotto/TwigCacheBundle/tree/master/Resources/doc/strategies.rst)
- [Profiler](https://github.com/EmanueleMinotto/TwigCacheBundle/tree/master/Resources/doc/profiler.rst)

License
-------

[](#license)

This bundle is under the MIT license. See the complete license in the bundle:

```
Resources/meta/LICENSE

```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity49

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 57.6% 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 ~190 days

Recently: every ~119 days

Total

14

Last Release

1652d ago

Major Versions

0.2.1 → 1.0.02015-08-04

PHP version history (2 changes)1.0.4PHP ^5.6|^7.0

1.3.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/30b6fbd038f22a54716027eb7ce30c6cafd8e59c138ae58b3c2516c34ccfef7f?d=identicon)[EmanueleMinotto](/maintainers/EmanueleMinotto)

---

Top Contributors

[![EmanueleMinotto](https://avatars.githubusercontent.com/u/417201?v=4)](https://github.com/EmanueleMinotto "EmanueleMinotto (49 commits)")[![toooni](https://avatars.githubusercontent.com/u/241080?v=4)](https://github.com/toooni "toooni (17 commits)")[![itinance](https://avatars.githubusercontent.com/u/1758597?v=4)](https://github.com/itinance "itinance (8 commits)")[![cached](https://avatars.githubusercontent.com/u/202738?v=4)](https://github.com/cached "cached (3 commits)")[![sspooky13](https://avatars.githubusercontent.com/u/25614491?v=4)](https://github.com/sspooky13 "sspooky13 (3 commits)")[![mente](https://avatars.githubusercontent.com/u/391997?v=4)](https://github.com/mente "mente (2 commits)")[![rvanlaak](https://avatars.githubusercontent.com/u/2707563?v=4)](https://github.com/rvanlaak "rvanlaak (1 commits)")[![DenysMedvid](https://avatars.githubusercontent.com/u/639684?v=4)](https://github.com/DenysMedvid "DenysMedvid (1 commits)")[![takeit](https://avatars.githubusercontent.com/u/562536?v=4)](https://github.com/takeit "takeit (1 commits)")

---

Tags

symfonybundletwigcache

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[yellowskies/qr-code-bundle

Symfony Barcode &amp; QR Code Generator Bundle with Twig extension

36682.9k](/packages/yellowskies-qr-code-bundle)[jbouzekri/phumbor-bundle

A Symfony Bundle to use the minimal Thumbor PHP client from webfactory/phumbor

25740.0k1](/packages/jbouzekri-phumbor-bundle)[nucleos/antispam-bundle

This bundle provides some basic features to reduce spam in symfony forms.

52105.1k](/packages/nucleos-antispam-bundle)[dms/twig-extension-bundle

DMS Twig Extension Bundle, leverages Fabien Potencier's extra twig extensions for your website.

19296.3k](/packages/dms-twig-extension-bundle)[cg/kint-bundle

This bundle lets you use the Kint function in your Twig templates. Kint is a print\_r() replacement which produces a structured, collapsible and escaped output

22125.8k1](/packages/cg-kint-bundle)[eschmar/time-ago-bundle

Provides a simple twig filter for expressing time difference in words.

1851.4k](/packages/eschmar-time-ago-bundle)

PHPackages © 2026

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