lessphp

LESS compiler written in PHP

  • 所有者: leafo/lessphp
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Build Status

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
主編程語言PHP
編程語言Makefile (語言數: 4)
平台
許可證Other
所有者活动
創建於2009-07-21 04:00:36
推送於2024-05-16 00:46:15
最后一次提交2018-10-16 20:24:03
發布數23
最新版本名稱v0.5.0 (發布於 )
第一版名稱v0.1.0 (發布於 )
用户参与
星數2.2k
關注者數102
派生數523
提交數569
已啟用問題?
問題數498
打開的問題數186
拉請求數47
打開的拉請求數32
關閉的拉請求數88
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?