我正在尝试设置一个 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 文件保存在哪里?我可以指定它的目的地吗?任何帮助将不胜感激。
最佳答案
根据其文档,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);
?>
关于php - LESS.php - 它在哪里保存编译后的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39838660/