Skip to content

Instantly share code, notes, and snippets.

@marfillaster
Created August 22, 2013 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marfillaster/6307586 to your computer and use it in GitHub Desktop.
Save marfillaster/6307586 to your computer and use it in GitHub Desktop.
Symfony2 automatic asset versioning. `nginx symfony version`
imports:
- { resource: release.php }
- { resource: config.yml }
framework:
templating:
assets_version: %release_version%
assets_version_format: "assets/rev/%%2$s/%%1$s"
location ~ assets/rev/ {
rewrite ^(.*?)/assets/rev/(.*?)/(.*)$ $1/$3 break;
}
<?php
$root = $container->getParameter('kernel.root_dir');
$head = file_get_contents($root.'/../.git/HEAD');
preg_match('#^ref: (.+?)$#', $head, $matches);
$version = file_get_contents($root.'/../.git/'.$matches[1]);
$container->setParameter('release_version', substr($version, 0, 7));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment