Skip to content
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

KO3 LESS Module v.1.1.1

LESS Module is a port of Leaf Corcoran's LESSPHP for Kohana 3 It adopts some of Alex Sancho's Kohana 2.3 Assets Module codes for CSS compression, credits goes to them Thanks to cheeaun for helping out! You might also want to check out another implementation from jeremeamia.

To Use

  1. Put the less module folder in your Modules directory
  2. Include less module in your application's bootstrap: 'less' => MODPATH.'less'
  3. Copy the less config file from /modules/less/config/less.php to your application's config directory
  4. From your less.php config file, put the 'path' to where you want the CSS files compiled / compressed, the folder must be writable
  5. You can set 'compress' to TRUE on your less.php config file if you want your CSS files to be combined in to one file and compressed (to lessen server calls)

Sample Code

Default less files extension is set in Less::$extension and is .less.

** MODPATH/baseModule/media/css/layout.less **

    @bodyBkgColor: #EEE;

    body {
        background: @bodyBkgColor;

        h1 { font-size: 3em; }

** APPPATH/media/css/style.less **

    @divBkgColor: #DDD;

    .roundedCorners (@radius:8px) {

    div {
        background: @divBkgColor;

        p { .roundedCorners(5px); }

** APPPATH/config/less.php **

    return array(
        // relative PATH to a writable folder to store compiled / compressed css
        // path below will be treated as: DOCROOT . 'media/css/'
        'path'     => 'media/css/',
        'compress' => TRUE,

** In your controller **

    class Controller_Sample extends Controller_Template {

        public $template = 'template';

        public function action_example1()
            // no need to add .less extension
            // you can put your less files anywhere
            $less_files = array

            $this->template->stylesheet = Less::compile($less_files);

        public function action_example2()
            // you can pass just single file

            $this->template->stylesheet = Less::compile(APPPATH.'media/css/style');

** In your template **

        <title>LESS for Kohana</title>
        <?= $stylesheet; // will give me ONE compressed css file located in /media/css/ ?>
        <h1>LESS for Kohana or Kohana for LESS?</h1>


Please report it to the issues tracker..

Something went wrong with that request. Please try again.