Clone this wiki locally
This is something a have built just for the fun of it, heavily inspired by YUI php loader. Uses the YUI Compressor and, optionally, Google Closure.
Ex 1: Using the request_uri, probably works in most cases
new ComboLoader($_SERVER['REQUEST_URI'][, array('use_cache' => true)]);
Ex 2: Using the auto method to detect what works
$comboLoader = new ComboLoader([array('use_cache' => true)]);
Ex 3: Using the handle method and also doing some config
$comboLoader = new ComboLoader();
Lets say your host is name combo.com and a request comes looking like this:
The files that will be served are all the ones from the “version/Component-A/Scripts” directory and “version/Component-B/Scripts/a-js-file.js”.
“version/Component-A.js” means load all files in the “Scripts” of that component.
“version/Component-B/a-js-file.js” means just load the single “a-js-file.js” in that components “Scripts” directory.
And of course you could also request the file by the full path ex. “version/Component-B/Scripts/a-js-file.js”, but who wants to write more?
So by requesting a .js-file the ComboLoader knows that the file it will be looking for is located in the “Scripts” directory of that component.
The same files are loaded as in example 1 but here we are setting the version as a global for all files requested, even less to write, yay :D
Note: You can still request a different version by prepending the version to a single param.
Scripts If a .js-file look for it here
Styles If a .css-file look for it here
Assets The root directory
/tmp The combined and minified file are stored here
blank Set this in order to be able to use the YUI compressor
[0-9]+ A simple pattern to figure out what part is the version
text/css .css-files will be served with this content-type
false Set to true to enable caching of served files
true Set to false to disable minification of served files
YUI Possible values are YUI or Closure
Assets The place where all your file are
Version A subfolder per version
Components A Components folder that hold all your different componets
Component-A Name of a component
- Component-A Name of a component
- Components A Components folder that hold all your different componets
- Version A subfolder per version