serebro / assets-manager
1.0
2015-02-13 23:36 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: >=4.0
This package is not auto-updated.
Last update: 2024-10-26 16:05:20 UTC
README
It can work with "rev-manifest.json" file of gulp-rev plugin.
$env = 'prod'; $revisionMap = json_decode(file_get_contents('build/manifest.json'), true); // { "file1.js": "file2-73a4818b.min.js", "file2.js": "file2-54e1080b.min.js" } $ar = new \Serebro\Assets\Revision($env); $ar->setRevisionMap($revisionMap)->setPrefix('http://cdn.example.com'); $assetsManager = \Serebro\Assets\Manager::getInstance(); $assetsManager ->setRevisionManager($ar) ->collection('head') ->addCss('main.css') ->addJs('file1.js') ->collection('body') ->addCss('special.css') ->addJs('file2.js'); echo $assetsManager->outputCss('head') . PHP_EOL; echo $assetsManager->outputJs('head') . PHP_EOL; echo $assetsManager->outputCss('body') . PHP_EOL; echo $assetsManager->outputJs('body') . PHP_EOL;
Result:
<link rel="stylesheet" href="http://cdn.example.com/css/main.css"/> <script type="text/javascript" src="http://cdn.example.com/js/file1-73a4818b.min.js"></script> <link rel="stylesheet" href="http://cdn.example.com/css/special.css"/> <script type="text/javascript" src="http://cdn.example.com/js/file2-54e1080b.min.js"></script>