Skip to content

Instantly share code, notes, and snippets.

@simshaun
Created February 26, 2014 00:11
Show Gist options
  • Save simshaun/9220732 to your computer and use it in GitHub Desktop.
Save simshaun/9220732 to your computer and use it in GitHub Desktop.
Sample stand-alone Assetic usage
$name = 'js';
$outputPath = 'assets/js/cache';
$assets = array(
'file1.js',
'file2.js',
);
$filterManager = null;
// $filterManager = new \Assetic\FilterManager();
// $filterManager->set('cssrewrite', new \Assetic\Filter\CssRewriteFilter());
// -------------------------------------------------------- //
$factory = new \Assetic\Factory\AssetFactory(DOCROOT);
$am = new \Assetic\Factory\LazyAssetManager($factory);
$worker = new \Assetic\Factory\Worker\CacheBustingWorker($am);
$filters = array();
if ($filterManager instanceof \Assetic\FilterManager) {
$factory->setFilterManager($filterManager);
$filters = $filterManager->getNames();
}
$factory->addWorker($worker);
$outputPath = trim($outputPath, '/');
$asset = $factory->createAsset($assets, $filters, array(
'name' => $name,
'output' => $outputPath.'/*',
));
$writer = new \Assetic\AssetWriter(DOCROOT);
$writer->writeAsset($asset);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment