Skip to content

Symfony 2 Bundle for asm89/twig-cache-extension

Notifications You must be signed in to change notification settings

takeit/TwigCacheBundle

 
 

Repository files navigation

Twig cache extension Bundle

Build Status SensioLabs Insight Coverage Status Scrutinizer Code Quality Total Downloads

Symfony 2 Bundle for asm89/twig-cache-extension.

API: emanueleminotto.github.io/TwigCacheBundle

Step 1: Download the Bundle

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 installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new EmanueleMinotto\TwigCacheBundle\TwigCacheBundle(),
        );
    }
}

Step 3: Configuration

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

Usage

The default strategy is the IndexedChainingCacheStrategy so you can use directly this code in your Twig 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:

License

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

Resources/meta/LICENSE

About

Symfony 2 Bundle for asm89/twig-cache-extension

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 76.1%
  • HTML 21.0%
  • Shell 2.9%