sunnyphp/yii2-less.php

This is a Yii2 wrapper extension for PHP port of the official LESS processor http://lesscss.org.

Installs: 607

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 6

Type:yii2-extension

1.1.0 2023-08-15 21:41 UTC

This package is auto-updated.

Last update: 2024-04-15 23:41:28 UTC


README

This is a Yii2 wrapper extension for PHP port of the official LESS processor http://lesscss.org. Used composer package Wikimedia\Less.php under hood.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require sunnyphp/yii2-less.php "*"

or add

"sunnyphp/yii2-less.php": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it (without dots) in your config:

$config = [
    ...
    'components' => [
		...
        'assetManager' => [
            ...
            'converter' => [
                'class' => 'SunnyPHP\Yii2\LessPHP\AssetConverter',
                'compress' => true, // Optional: You can tell less.php to remove comments and whitespace to generate minimized css files.
                'useCache' => true, // Optional: less.php will save serialized parser data for each .less file. Faster, but more memory-intense.
                'cacheDir' => '@web/cache', // Optional: is passed to the SetCacheDir() method. Default cache directory in composer package directory.
                'cacheSuffix' => true, // Optional: Filename suffix to avoid the browser cache and force recompiling by configuration changes
                'outputDir' => '@web/assets', // Optional: Output files directory (watch out: all converted files saves in single directory!)
            ],
			...
        ],
		...
	],
	...
];

So if it is configured you can specify your less files in asset bundle:

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.less',
    ];
    public $js = [
    ];
    public $depends = [
    ];
}