Created
July 25, 2013 12:15
-
-
Save stephencoe/6079086 to your computer and use it in GitHub Desktop.
less auto compile in Zend Framework 1.12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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