The symfony 3 bundle for PhpFastCache integrating a phpfastcache service, a twig cache tag and a powerfull cache profiler integrated to the symfony profile
Latest commit 2fd3b46 Dec 26, 2016 @Geolim4 Geolim4 Updated version

Code Climate Scrutinizer Code Quality Build Status Latest Stable Version Total Downloads Dependency Status License

Symfony 3 PhpFastCache Bundle

👍 Step 1: Include phpFastCache Bundle in your project with composer:

composer require phpfastcache/phpfastcache-bundle

🚧 Step 2: Setup your config.yml to configure your cache(s) instance(s)

# PhpFastCache configuration
    twig_driver: "filecache" # This option must be a valid declared driver, in our example: "filecache"
    twig_block_debug: false # This option will wrap CACHE/ENDCACHE blocks with block debug as HTML comment
            type: Files
                path: "%kernel.cache_dir%/phpfastcache/"
  • More examples in Docs/Example/app/config

🔧 Step 3: Setup your AppKernel.php by adding the phpFastCache Bundle

$bundles[] = new phpFastCache\Bundle\phpFastCacheBundle();
  • See the file Docs/Example/app/AppKernel.php for more information.

🚀 Step 4: Accelerate your app by making use of PhpFastCache service

Caching data in your controller:

public function indexAction(Request $request)
    $cache = $this->get('phpfastcache')->get('filecache');
    $item = $cache->getItem('myAppData');

    if (!$item->isHit() || $item->get() === null) {
        $item->set('Wy app has now superpowers !!')->expiresAfter(3600);//1 hour

    // replace this example code with whatever you need
    return $this->render('default/index.html.twig', [
        'myAppData' => $item->get(),
        'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),

Or in your template:

     * 'myrandom6' Is your cache key identifier, must be unique
     * 300 Is the time to live (TTL) before the cache expires and get regenerated
    {% cache 'myrandom6' 300 %}
            <!-- Some heavy stuff like Doctrine Lazy Entities -->
            {% for i in 1..1000 %}{{ random() }}{% endfor %}
    {% endcache %}

💥 phpFastCache Bundle support

Found an issue or had an idea ? Come here here and let us know !