Coder Social home page Coder Social logo

lessphp's Introduction

lessphp v0.2.0

lessphp is a compiler for LESS written in php. For a complete description of the language see http://leafo.net/lessphp/docs/

How to use in your php project

Copy less.inc.php to your include directory and include it into your project.

There are a few ways to interface with the compiler. The easiest is to have it compile a LESS file when the page is requested. The static function less::ccompile, checked compile, will compile the input LESS file only when it is newer than the output file.

try {
	lessc::ccompile('input.less', 'output.css');
catch (exception $ex) {
	exit($ex->getMessage());
}

Note that all failures with lessc are reported through exceptions. If you need more control you can make your own instance of lessc.

$input = 'mystyle.less';

$lc = new lessc($input);

try {
	file_put_contents('mystyle.css', $lc->parse());
} catch (exception $ex) { ... }

In addition to loading from file, you can also parse from a string like so:

$lc = new lessc();
$lesscode = 'body { ... }';
$out = $lc->parse($lesscode);

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.

lessphp's People

Contributors

leafo avatar simensen avatar iloveitaly avatar xdissent avatar everzet avatar lopo avatar anqqa avatar shnhrrsn avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.