yii-eassetmanager Extended Asset Manager which compiles LESS files on-the-fly

  1. Installation
  2. Usage
  3. Resources

Extended Asset Manager Compiles .less file(s) on-the-fly and publishes output .css file. It uses lessphp by Leaf Corcoran - LESS PHP compiler and parser.

The main feature of this extention is what you can publish .less files with assetManager the same way as .css files. EAssetManager automatically track all .less files for changes and recompiles output .css file on-the-fly (this feature can be disabled in production mode).


  1. Copy EAssetManager.php to /protected/extensions/ directory
  2. Download the latest version of lessphp from http://leafo.net/lessphp and put lessc.inc.php file under /protected/extensions/EAssetManager/ directory
  3. Add or replace the assetManager component in /protected/config/main.php like that:





See code of EAssetManager.php to read description of public properties.

  1. CHMOD 'lessCompiledPath' directory to 777 in order to create new files there by EAssetManager.
  2. Optional: enable Yii caching. Otherwise, EAssetManager will create (or use existing) directory /protected/runtime/cache/ and store cache data there. You can override this path by setting public property 'cachePath'.


Just publish .less file with assetManager like that:

$css = CHtml::asset(Yii::app()->basePath.'/vendors/bootstrap/bootstrap.less');

That's all :)

Also it might be useful to pre-compile .less files. For example, to make command which compiles .less files in background. In this case you can use "lessCompile" method:


Output .css file will be stored under 'lessCompiledPath' directory. And then add already compiled file in your application:

$css = CHtml::asset(Yii::app()->basePath.'/assets/css/bootstrap.css');


$css = CHtml::asset(Yii::app()->assetManager->lessCompiledPath.'/bootstrap.css');


2 0
Yii Version: Unknown
License: BSD-2-Clause
Category: User Interface
Developed by: Inpassor
Created on: Oct 16, 2013
Last updated: 9 years ago


show all