symfony/AsseticBundle — pull request #215 by vmattila (2013-07-28 14:26:53+00:00)
Title: Added assetic:list command to output list of asset files and their md5 hash

This PR introduces a new command, `assetic:list` that produces a list of all asset files and optionally an md5 hash from dumped output or source file contents:

```
$ app/console assetic:list --md5=file
429ec0da456d16a44ec609153322fa94 css/reset.css
71622ad6e734e307fb22437261e4b39a css/480.css
```

To output full file paths, use `--paths`:

```
429ec0da456d16a44ec609153322fa94 /var/www/symfony2-project/app/../web/css/reset.css
71622ad6e734e307fb22437261e4b39a /var/www/symfony2-project/app/../web/css/480.css
```

**Use Case: Cache Busting**

As there is not yet reliable cache busting solution (see for example https://github.com/symfony/AsseticBundle/pull/119 ), we do use the output of `assetic:list` to generate a master hash of all asset files:
`$ app/console --env=prod assetic:list --md5=file | md5sum`

If the master hash changes between deployments (meaning a source file content has changed, a new file is added, a file is renamed or removed), we'll do actual `assetic:dump` and upload new dumped files to CDN to an address prefixed with the master hash. The master hash is set to `framework.templating.assets_base_urls` configuration variable in `config.yml`.

`--md5=file` does not directly see changes which don't alter the sources but the output itself (filters, asset grouping etc). If it's required, one can use `assetic:list --md5=dump` that generates a hash from asset's dumped output.