lessphp icon indicating copy to clipboard operation
lessphp copied to clipboard

checkedCompile() requires absolute path or relative path?

Open ghost opened this issue 10 years ago • 1 comments

I'm having problems importing my import.less file. It's unclear what kind of value checkedCompile() requires. An absolute path? Relative path? Even when I put both lessc.inc.php and input.less in the root folder (of a MAMP installation) I get the "load error" message...

checkedCompile('input.less', "output.css");

ghost avatar Mar 07 '14 07:03 ghost

You can modify the script below to place your css file in the same folder or the folder you want to place with the below snippet.

<?php

    $root = 'your_web-folder/path/to/';
    $selected_styles = 1;
    require "lessc.inc.php";

    $inputFile = $root . "/templates/" . "template_name" . "/themes/style". $selected_styles ."/style.less";
    $outputFile = $root . "/templates/" . $this->template ."/themes/style". $selected_styles ."/style.css";

    $less = new lessc;
    $less->setFormatter("compressed");
    $cache = $less->cachedCompile($inputFile);

    file_put_contents($outputFile, $cache["compiled"]);

    $last_updated = $cache["updated"];
    $cache = $less->cachedCompile($cache);
        if ($cache["updated"] > $last_updated) {
            file_put_contents($outputFile, $cache["compiled"]);
        }

    // compiled css file
    echo '<link rel="stylesheet" type="text/css" href="'.$inputFile.'">';
?>

Shaz3e avatar Jan 12 '15 19:01 Shaz3e