Skip to content

Instantly share code, notes, and snippets.

@stephencoe
Created July 25, 2013 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephencoe/6079086 to your computer and use it in GitHub Desktop.
Save stephencoe/6079086 to your computer and use it in GitHub Desktop.
less auto compile in Zend Framework 1.12
protected function _initCss(){
require_once APPLICATION_PATH . "/../library/lessphp/lessc.inc.php";
$inputFile = APPLICATION_PATH."/../public/css/less/style.less";
$outputFile = APPLICATION_PATH."/../public/css/style.css";
// load the cache
$cacheFile = APPLICATION_PATH . "/../data/cache/css-compiled.less.cache";
if (file_exists($cacheFile)) {
$cache = unserialize(file_get_contents($cacheFile));
} else {
$cache = $inputFile;
}
$less = new lessc;
$newCache = $less->cachedCompile($cache);
if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) {
file_put_contents($cacheFile, serialize($newCache));
file_put_contents($outputFile, $newCache['compiled']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment