A simple class to generate js/css tags with cache names from busters.json. If you use gulp-buster to create a busters.json, it will look something like this:
{
"path/to/app.min.css": "f77f5bee5ef6a19bf63fe66aa0971576",
"path/to/app.min.js": "03cbc5dc0b5b117264ae74515cd3fb76"
}
Then you can put <?=$bustersPhp->assets()?>
in your view and it will display like this:
<link href="https://github.com/mikedfunk/BustersPhp/blob/master//mysite.com/path/to/app.min.f77f5bee5ef6a19bf63fe66aa0971576.css" rel="stylesheet">
<script src="https://github.com/mikedfunk/BustersPhp/raw/master//mysite.com/path/to/app.min.03cbc5dc0b5b117264ae74515cd3fb76.js"></script>
Get composer, then put this in your composer.json
in the "require" block:
"mikefunk/bustersphp": "1.1.*"
then run composer update
.
composer require MikeFunk/BustersPhp:dev-develop
<?php
use MikeFunk\BustersPhp\BustersPhp;
// optional config array - if you want to set a custom config
$config = array(
'rootPath' => '//'.$_SERVER['HTTP_HOST'],
'cssTemplate' => '<link href="https://github.com/mikedfunk/BustersPhp/blob/master/{{ROOT_PATH}}/{{FILE_PATH}}/{{FILE_NAME}}.{{HASH}}.css" rel="stylesheet">',
'jsTemplate' => '<script src="https://github.com/mikedfunk/BustersPhp/raw/master/{{ROOT_PATH}}/{{FILE_PATH}}/{{FILE_NAME}}.{{HASH}}.js"></script>',
'bustersJsonPath' => $_SERVER['DOCUMENT_ROOT'].'/assets/cache/busters.json',
);
$bustersPhp = new BustersPhp($config);
<!-- css link tagss -->
<?=$bustersPhp->css()?>
<!-- js script tags -->
<?=$bustersPhp->js()?>
<!-- js tags and css tags -->
<?=$bustersPhp->assets()?>
For more information check out gulp-buster