less

less - Compile your LESS server-side
47 followers

Current version 0.10.0

LESS is a modest extension that compiles LESS (dynamic stylesheets) server-side. If you haven't tried LESS you should definitely give it a go, you won't be disappointed.

Since version 0.10.0 the extension uses leafo's lessphp library. The reason I changed to use this library is because it compiles the newest version of Twitter's Bootstrap (2.0.3) which the previous library didn't.

Links

What's included?

  • LessCompiler - Wrapper for the compiler

Setup

Unzip the extension to protected/extensions/less and add the following to your main config:

'preload'=>array(
    .....
    'less', // preload the component to allow for automatic compilation
),
.....
'components'=>array(
    .....
    'less'=>array(
        'class'=>'ext.less.components.LessCompiler',
        'forceCompile'=>false, // indicates whether to force compiling
        'paths'=>array(
            'less/style.less'=>'css/style.css',
        ),
    ),
),

That's it! You're ready to start writing your stylesheets in LESS and forget about CSS. If you're not familiar with LESS you can start by reading the official documentation.

Changes

May 6, 2012

  • Release 0.10.0
    • Changed to use leafo's phpless library
    • Fixed checking for changes in paths configured to be compiled

Mar 8, 2012

  • Release 0.9.1
    • Added support for checking if recompiling is necessary
    • Added support for compressing compiled CSS
    • Added support for enabling compiler debugging mode
    • Removed LessCompilationBehavior (redundant)

Dec 1, 2011

  • Initial release

Total 10 comments

#8089 report it
wisp at 2012/05/09 09:40am
import

and doesn't seem to work with import statements

#8027 report it
yiiesss at 2012/05/04 07:12am
less compiler for bootstrap

try this less compiler for bootstrap

Could not compile latest bootstrap.less file
"Less\Exception\CompilerException:#grid > .core is undefined " Note that the file compiles fine with Winless.
#7656 report it
drumaddict at 2012/04/05 09:26am
Could not compile latest bootstrap.less file

"Less\Exception\CompilerException:#grid > .core is undefined " Note that the file compiles fine with Winless.

#7355 report it
demo88 at 2012/03/16 11:40am
@Stageline

The setup is a bit misleading:

'preload'=>array
    (
            'less',
            'log',
            'bootstrap',
    ),
    'components'=>array
    (
            'less'=>array( //the same as in preload
                    'autoCompile'=>true,
                    'class'=>'ext.less.components.LessCompiler',
                    'paths'=>array(
                            '/less/styles.less'=>'/css/style.css',
                    )
            ),
#7354 report it
Stageline at 2012/03/16 11:34am
can't load for me

Can't load ext form me. Whats wrong?

config/main.php

    'preload'=>array
    (
            'less',
            'log',
            'bootstrap',
    ),
    'components'=>array
    (
            'lessComplier'=>array(
                    'autoCompile'=>true,
                    'class'=>'ext.less.components.LessCompiler',
                    'paths'=>array(
                            '/less/styles.less'=>'/css/style.css',
                    )
            ),
            [....]

16:15:21.978339 trace system.CModule

Loading "log" application component in C:\Users\User\www\z3usproject\index.php (13)

16:15:21.983776 trace system.CModule

Loading "bootstrap" application component in C:\Users\User\www\z3usproject\index.php (13)

#7353 report it
dimvic7 at 2012/03/16 11:03am
Thanks, very useful plugin

Could you separate the parser from your extension (put it in vendors/, just require it) and support for a "from" and a "to" path to be given, so that every less file inside the "from" path gets compiled to the corresponding "to" path?

<from>/aa.less        ==>  <to>/aa.css
<from>/bb.less        ==>  <to>/bb.css
<from>/ii/cc.less     ==>  <to>/ii/cc.css
<from>/ii/jj/dd.less  ==>  <to>/ii/jj/dd.css
#7261 report it
Chris83 at 2012/03/08 03:43am
@schmunk

LessCompilationBehavior was removed a while ago, in the latest version you just add 'less' to your components to be preloaded if you want to use eager loading (which was previously done by the behavior).

#7257 report it
schmunk at 2012/03/07 11:39am
Can't find ext.less.components.LessCompilationBehavior on bitbucket?

Which commit is 0.9.0?

#6592 report it
borales at 2012/01/19 07:23pm
Automatic compilation

Why not compile the script depending on original file changes?

#5962 report it
schmunk at 2011/11/30 06:44pm
LESS looks awesome!

Thanks for linking that project.

Leave a comment

Please to leave your comment.

Create extension