Symfony Bundle to integrate gulp-buster npm package for cache busting

v1.0.1 2016-02-14 10:59 UTC

This package is not auto-updated.

Last update: 2020-07-24 19:44:19 UTC


Build Status Coverage Status Latest Stable Version Total Downloads License SensioLabsInsight

When using gulp to manage assets of a Symfony application, this Bundle will help in cache busting with help of gulp-buster package.


Install the latest version with

$ composer require ajaxray/gulp-buster-bundle

Then enable the bundle in AppKernel -

// app/AppKernel.php

public function registerBundles()
    $bundles = array(
        // ...
        new Ajaxray\GulpBusterBundle\GulpBusterBundle(),

How to use

Assuming you are using gulp-buster to generate hashes for your web assets (javascript, css, images etc. static resources).

Now the next thing is using those hashes with your web assets. This bundle will make it easy by adding a Twig Filter. Here is how to use this filter in Twig views -

<link rel="stylesheet" href="{{ asset('css/example.min.css')|with_buster_hash  }}">

If a hash is found for this file, it will be appended as query string with it's url -

<link rel="stylesheet" href="/css/example.min.css?v=771191ec8571a3f46afdb78f3e7bed17">

If no hash found for this file -

<link rel="stylesheet" href="/css/example.min.css?v=no-buster-hash-found">

That's all :)


By default, this bundle assumes the following paths -

  • busters.json (or any other name) file : %kernel.root_dir%/../busters.json
  • web dir: %kernel.root_dir%/../web
  • gulp dir (the dir of your gulpfile.js): %kernel.root_dir%/..

If any/all of the above is different for you, you can configure from your app/config/config.yml file using following keys -

    # if you've configured it to be in web dir    
    busters_file: "%kernel.root_dir%/../web/busters.json"    
    web_dir: "%kernel.root_dir%/relative/path/to/web/dir"    
    gulp_dir: "%kernel.root_dir%/relative/path/to/dir"