Lilo is a fast engine that allow you scan a file to extract a dependency graph using a subset of Sprockets directives. This class supports the following directives:
//= require
//= require_directory
//= require_tree
For more information about them please visit [Sprockets] (https://github.com/sstephenson/sprockets).
In your files, write Sprockets-style comments to indicate dependencies, e.g.
//= require dependency
If you want to bring in a whole folder of files, use
//= require_tree dir
Lilo supports the three Sprockets-style comments, for more information about them please visit [Sprockets] (https://github.com/sstephenson/sprockets).
In your script:
require_once 'path/to/libs/diacronos/Lilo/Lilo.php';
use \diacronos\Lilo\Lilo;
$lilo = new Lilo(array(/* extensions */));
Lilo uses extensions to determine if a file should be processed or not. For example, for working with Javascript and CoffeeScript files:
require_once 'path/to/libs/diacronos/Lilo/Lilo.php';
use \diacronos\Lilo\Lilo;
$lilo = new Lilo(array('js', 'coffee'));
The load path is an ordered list of directories that Lilo
uses to search for files. These must be configured before to work with the library:
$lilo->appendPath('path/to/files/dependencies/1');
$lilo->appendPath('path/to/files/dependencies/2');
....
Each Lilo
instance use a DepGraph
instance. You can scan
a file to just update the dependency graph:
$lilo->scan('dir/foo.coffee');
Later you can get an array of filenames showing the series of dependencies the scanned file has:
$result = $lilo->getChain('dir/foo.coffee');
You can get an array of filenames and contents showing the series of dependencies the scanned file has:
$result = $lilo->getFileChain('dir/foo.coffee');
The result is in the format array(array('filename' => 'dependency1.js', 'content' => "// file dependency1.js content"), ...)
.
Lilo is a PHP library inspired by [Sprockets] (https://github.com/sstephenson/sprockets) and based in [Snockets] (https://github.com/TrevorBurnham/snockets). All credits for them.