leafo/lessphp
Composer 安装命令:
composer require leafo/lessphp
包简介
lessphp is a compiler for LESS written in PHP.
README 文档
README
lessphp v0.5.0
http://leafo.net/lessphp
lessphp is a compiler for LESS written in PHP. The documentation is great,
so check it out: http://leafo.net/lessphp/docs/.
Here's a quick tutorial:
How to use in your PHP project
The only file required is lessc.inc.php, so copy that to your include directory.
The typical flow of lessphp is to create a new instance of lessc,
configure it how you like, then tell it to compile something using one built in
compile methods.
The compile method compiles a string of LESS code to CSS.
<?php require "lessc.inc.php"; $less = new lessc; echo $less->compile(".block { padding: 3 + 4px }");
The compileFile method reads and compiles a file. It will either return the
result or write it to the path specified by an optional second argument.
<?php echo $less->compileFile("input.less");
The checkedCompile method is like compileFile, but it only compiles if the output
file doesn't exist or it's older than the input file:
<?php $less->checkedCompile("input.less", "output.css");
If there any problem compiling your code, an exception is thrown with a helpful message:
<?php try { $less->compile("invalid LESS } {"); } catch (exception $e) { echo "fatal error: " . $e->getMessage(); }
The lessc object can be configured through an assortment of instance methods.
Some possible configuration options include changing the output format,
setting variables from PHP, and controlling the preservation of
comments, writing custom functions and much more. It's all described
in the documentation.
How to use from the command line
An additional script has been included to use the compiler from the command line. In the simplest invocation, you specify an input file and the compiled css is written to standard out:
$ plessc input.less > output.css
Using the -r flag, you can specify LESS code directly as an argument or, if the argument is left off, from standard in:
$ plessc -r "my less code here"
Finally, by using the -w flag you can watch a specified input file and have it compile as needed to the output file:
$ plessc -w input-file output-file
Errors from watch mode are written to standard out.
The -f flag sets the output formatter. For example, to compress the output run this:
$ plessc -f=compressed myfile.less
For more help, run plessc --help
leafo/lessphp 适用场景与选型建议
leafo/lessphp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.27M 次下载、GitHub Stars 达 2.18k, 最近一次更新时间为 2012 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 leafo/lessphp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 leafo/lessphp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.27M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2213
- 点击次数: 31
- 依赖项目数: 184
- 推荐数: 49
其他信息
- 授权协议: MIT
- 更新时间: 2012-05-25