Use the live demo to test the compiler using your own code, or click through the example buttons to see various parts of the language.

For an overview of the syntax take a look at the lessphp documentation .

The entire compiler comes in a single includable class, but an additional command line interface to the compiler is included. It will run on PHP 5.1+. See the quick start for basic usage.

lessphp is a compiler for LESS written in PHP.

If you use Packagist for installing packages, then you can update your composer.json like so:

Quick Start

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.

echo $less -> compileFile ( "input.less" );

The compileChecked method is like compileFile , but it only compiles if the output file doesn’t exist or it’s older than the input file:

$less -> checkedCompile ( "input.less" , "output.css" );

If there any problem compiling your code, an exception is thrown with a helpful message:

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.

Documentation

A complete reference manual can be found on the documentation page.

A list of changes is available on the changelog page.

Plugins

Various lessphp plugins exist for many frameworks:

If you've got one, email me it and I'll post it here.

Issues

If you find something that isn’t working right feel free to leave a comment or post on the GitHub issues tracker. If you have any interesting ideas for additions to the language please do suggest them as well. You can also email me if you want.

Comments

If you have a GitHub account, you can post bug reports on the github issues tracker.