【问题标题】:LESS.php - where does it save the compiled file?LESS.php - 它在哪里保存编译文件?
【发布时间】:2017-02-11 19:32:54
【问题描述】:

我正在尝试设置一个 php LESS 解析器:less.php (https://github.com/oyejorge/less.php#basic-use)。

我已经从示例中编写了一个基本代码:

<?php
  require_once 'less.php/Less.php';

  $parser = new Less_Parser();
  $parser->parseFile( 'Z:\home\test1\www\assets\bootstrap\less\bootstrap.less', 'test' );
  $css = $parser->getCss();
?>

应该从给定文件夹编译 bootstrap.less 文件。它可以正常工作,但是我不确定它将编译的css文件保存在哪里?我可以指定它的目的地吗?任何帮助将不胜感激。

【问题讨论】:

    标签: php html css twitter-bootstrap less


    【解决方案1】:

    根据其文档,getCss 不保存 CSS。事实上,变量$css 将包含CSS。要将$css 的值写入磁盘,例如使用file_put_contents。即:

    <?php
    require_once 'less.php/Less.php';
    
    $parser = new Less_Parser();
    $parser->parseFile( 'Z:\home\test1\www\assets\bootstrap\less\bootstrap.less', 'test' );
    $css = $parser->getCss();
    
    // And now to write the contents:
    file_put_contents("output.css", $css);
    ?>
    

    【讨论】:

    • 感谢这个 Martijn。我对PHP不太熟悉,所以在这一点上我有点困惑。
    猜你喜欢
    • 1970-01-01
    • 2015-07-10
    • 2014-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多