https://github.com/unframework/lessphp
LESS compiler written in php
https://github.com/unframework/lessphp
Last synced: 6 months ago
JSON representation
LESS compiler written in php
- Host: GitHub
- URL: https://github.com/unframework/lessphp
- Owner: unframework
- License: other
- Fork: true (leafo/lessphp)
- Created: 2011-09-09T17:58:23.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-09-09T07:23:32.000Z (over 14 years ago)
- Last Synced: 2024-04-14T18:22:16.353Z (almost 2 years ago)
- Language: PHP
- Homepage: http://leafo.net/lessphp
- Size: 269 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lessphp v0.2.0
####
`lessphp` is a compiler for LESS written in php.
For a complete description of the language see
### How to use in your php project
Copy lessc.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
`lessc::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.