2017 © Pedro Peláez
 

library less4laravel

Bringing lessphp into Laravel

image

jtgrimes/less4laravel

Bringing lessphp into Laravel

  • Sunday, August 2, 2015
  • by jtgrimes
  • Repository
  • 4 Watchers
  • 19 Stars
  • 3,018 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 19 Versions
  • 2 % Grown

The README.md

Less4Laravel

Allows you to use Less in Laravel 5 with no fuss, no muss., (*1)


If you're still using Laravel 4, please lock your composer version to '~0.3'. Check out the README_L4.md file for more Laravel 4 instructions


License

Less4Laravel is open-sourced software licensed under the MIT license, the same license Laravel uses., (*2)

Installation

Via Composer, (*3)

$ composer require jtgrimes\less4laravel

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

'Jtgrimes\Less4laravel\LessServiceProvider'

In the aliases section, add:, (*5)

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

Configuration

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

$ php artisan vendor:publish

The defaults are:, (*7)

  • Recompile whenever any .less file is updated.
  • Cache .less files in /storage/framework/cache
  • Store .less files in resources/assets/less
  • Store generated .css files in public/css
  • Link to /css/filename.css
  • Don't minify the generated css file

All of these defaults can be changed in /app/config/less4laravel.php., (*8)

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., (*9)

In order to have different configs on your development and production servers, you'll do something like this:, (*10)

Open up less4laravel.config and change, (*11)

    'compile_frequency' => 'changed',

to, (*12)

    'compile_frequency' => env('LESS4LARAVEL_FREQUENCY'),

You can use any environment variable name you want -- L4L_FREQ is an example., (*13)

In your local .env file, add, (*14)

    'LESS4LARAVEL_FREQUENCY' => 'changed',

and in your production .env file, add, (*15)

    'LESS4LARAVEL_FREQUENCY' => 'never'

Usage

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., (*16)

If you're using Laravel Blade, be sure to un-escape your call to Less:, (*17)

    {!! Less::to('file') !!}

To add properties to your link, just put them in an array as the second variable to the to function: Less::to('filename', ['media'=>'print']) will generate <link media="print" type="text/css" rel="stylesheet" href="http://localhost/css/filename.css">, (*18)

You can also use the Less::link() function if you don't want Less4Laravel generating your html:, (*19)

    <link rel="stylesheet" href="{!! Less::link('filename') !!}">

Credits

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

The Versions

02/08 2015

dev-master

9999999-dev

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

02/08 2015

dev-dev/oyejorge

dev-dev/oyejorge

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel less

02/08 2015

1.2.0

1.2.0.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

19/06 2015

1.1.1

1.1.1.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

18/06 2015

1.1.0

1.1.0.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

06/02 2015

1.0.2

1.0.2.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

06/02 2015

1.0.1

1.0.1.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

04/02 2015

dev-Laravel-4

dev-Laravel-4

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

04/02 2015

dev-laravel5

dev-laravel5

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

04/02 2015

1.0.0

1.0.0.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

05/07 2014

0.3.0

0.3.0.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

24/08 2013

0.2.0

0.2.0.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

09/07 2013

0.1.6

0.1.6.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

04/06 2013

0.1.5

0.1.5.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

09/05 2013

0.1.4

0.1.4.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

17/01 2013

0.1.3

0.1.3.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

17/01 2013

0.1.2

0.1.2.0

Bringing lessphp into Laravel

  Sources   Download

MIT

The Requires

 

laravel less

17/01 2013

0.1.1

0.1.1.0

Bringing lessphp into Laravel

  Sources   Download

The Requires

 

17/01 2013

0.1.0

0.1.0.0

Bringing lessphp into Laravel

  Sources   Download

The Requires