Copyright (c) 2009 Chad Auld (opensourcepenguin.net) Licensed under the MIT license
- Place Lissa somewhere under DOCUMENT_ROOT
- Alter includes/lissa/config.inc.php as needed
- Set the proper $min_cachePath in includes/minify/min/config.php (and perhaps $min_documentRoot if things don't work as is)
- Drop additional YUI releases into the includes/js/yui/lib as needed. YUI 2.8.0r4 is supplied by default.
- Drop corresponding YUI Metadata files into the includes/js/yui/lib/meta folder for each new YUI release you add (see step 4). The metadata files are shipped with YUI PHP Loader and are located in the lib/meta folder.
HOW DOES IT WORK
OK enough already... How do you use it? Simple.
//Grab the class require 'includes/lissa/class.lissa.php'; //Create a custom module metadata set $customModules = array( "customJS" => array( "name" => 'customJS', "type" => 'js', // 'js' or 'css' "fullpath" => 'includes/js/example.js', "requires" => array("event", "dom", "json") ), "sampleData" => array( "name" => 'sampleData', "type" => 'js', // 'js' or 'css' "fullpath" => 'includes/js/sample_data.js', "requires" => array("customJS") ), "customCSS" => array( "name" => 'customCSS', "type" => 'css', "fullpath" => 'includes/css/example.css' ) ); //Get a new Lissa instance which includes our custom metadata along with the base YUI metadata $loader = new Lissa("2.8.0r4", null, $customModules); $loader->load("fonts", "sampleData", "customCSS"); //Then just output the link and/or script nodes by calling one of three methods; scripts, css, tags $loader->tags();
With the setup show above we'll end up with the following to includes:
If you are paying close attention you'll notice the handoff to Minify and the comma separated list of resources that will be minified, combined, cached, and served.
For a simple example see index.php.
For a more complex integration done around the same idea check out the Aliro Resource Loader. Lissa is a more generic spinoff of the aliroResourceLoader class.
Take Lissa and work it into your own project. You'll most likely change things along the way to fit your environment/project, but hopefully this will serve as solid starting point. Stop reading, start coding.