Skip to content
Bringing Less to Laravel
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Allows you to use Less in Laravel 4 with no fuss, no muss.


Add jtgrimes\less4laravel as a requirement to composer.json:

    "require": {
        "Jtgrimes/less4laravel": "0.1.*"

Update your packages with composer update or install with composer install.

Once Composer has installed or updated your packages you need to register Less4Laravel with Laravel itself. Open up app/config/app.php and find the providers key towards the bottom and add:


In the aliases section, add:

'Less'  =>  'Jtgrimes\Less4laravel\LessFacade'


In order to work with the configuration file, you're best off publishing a copy with Artisan:

$ php artisan config:publish Jtgrimes/less4laravel

The defaults are:

  • Recompile whenever the .less file is updated. (Recompilation only happens when the named file is changed. If other files are imported, changing them will not trigger a recompile.)
  • Store .less files in app/less
  • Store generated .css files in public/css
  • Link to /css/filename.css

All of these defaults can be changed in /app/config/packages/Jtgrimes/less4laravel.php.

Additionally you can (and probably should) have different configurations for development and production. Specifically, you probably don't want to be generating css files on your production server, since it will slow down your site.


In your view file, just call Less::to('file') to compile the .less file (if needed) and generate a link to the output css file.

Artisan Commands

They're not implemented yet, but compiling .less files from Artisan is on the to-do list.


Less4Laravel doesn't exist without Leaf Corcoran's lessphp. lessphp doesn't exist without LESS. Less4Laravel also requires Laravel. The readme is largely boosted from Rob Crowe's readme for (the very awesome) TwigBridge.

Something went wrong with that request. Please try again.