PHP Classes

Less.php: Parse and process Leaner CSS files

Recommend this page to a friend!
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 49%Total: 463 All time: 6,061 This week: 455Up
Version License PHP version Categories
less-php 1.0.0BSD License5.0PHP 5, Text processing, Templates


This process can be used to parse and process Leaner CSS (LESS) files.

It can parse LESS template files and process it by reading and replacing variable values, insert mixins in class declarations that use them, evaluating operations and expand nested definitions into CSS classes.

The processed CSS is returned as a string.

Picture of Diogo Resende
Name: Diogo Resende <contact>
Classes: 10 packages by
Country: Portugal Portugal
Age: 41
All time rank: 292 in Portugal Portugal
Week rank: 311 Down4 in Portugal Portugal Down
Innovation award
Innovation award
Nominee: 4x

Winner: 2x


Less.php let's you convert .less files into .css Versions -------- 0.0.1 - First official release (beta) 0.0.3 - Stable release; bug fixes; nested functions support; @if operator support How to Use ---------- Run on the console: lessc file.less > output.css If you want you can check the lessc file so you can use the class inside your code. Supported --------- - variables - mixins - nested rules - operations - comments (C-style and inline) - math functions (min, max, avg, round, ceil, floor) - color functions (lighten, darken, greyscale) Missing ------- - namespaces & accessors TBD --- - dataurl() function to embed images in css - suggestions? EXAMPLE ------- @light-blue: #111 + #111; @default-border: .4em; @max-border: 2em; /** * First comment **/ .bordered (@radius: 3px; @shadow-color: rgba(100, 100, 100, .5)) { border-radius: @radius; -moz-border-radius: @radius; -webkit-border-radius: @radius; box-shadow: 0 0 3px @shadow-color; -moz-box-shadow: 0 0 3px @shadow-color; -webkit-box-shadow: 0 0 3px @shadow-color; } #header, #content { // second comment @red-color: #abcdef + #111; // other comment a:active, a:hover { text-decoration: none; // one more comment border: @default-border + .2 solid black; background: url(some/file.png) left center repeat-x; } color: @light-blue * 2; .bordered ( 5px, ); :hover { color: @red-color; } .item { color: #af6788; } &.item { color: red; } } #nav { margin: min(@max-border, 1em, .5em); color: darken(#ccc, 20%); // same as lighten(#ccc, -20%) background: greyscale(#f00); } .foo { &.bar { color: black }}

  Files folder image Files  
File Role Description
Files folder imagelib (3 files)
Accessible without login Plain text file lessc Appl. LESS compiler
Accessible without login Plain text file README Doc. Docs
Accessible without login Plain text file reset.css Data Part of the test
Accessible without login Plain text file test.less Data Part of the test
Accessible without login Plain text file test2.less Data Part of the test

  Files folder image Files  /  lib  
File Role Description
  Plain text file common.less.class.php Class Base class (common methods)
  Plain text file entities.less.class.php Class Entities found on LESS code (Scope, Declaration, Property, ..)
  Accessible without login Plain text file functions.less.class.php Aux. Extended functions

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,061
This week:455Up
 User Ratings  
 All time