A module wrapper for Wikimedia’s Less parser that compiles .less files to .css. Also used by the ProcessWire core for AdminThemeUikit customization.

Less parser for ProcessWire

This is a ProcessWire module wrapper for the Wikimedia LESS parser. Originally developed by Bernhard Baumrock with additions by Ryan Cramer. Requires ProcessWire 3.0.164+.

Requirements


  • ProcessWire 3.0.179 or newer (3.0.229+ preferable)
  • PHP 7.4 or newer

Install


  1. Copy all files included in this module into new directory /site/modules/Less/.
  2. In the ProcessWire admin, go to Modules > Refresh.
  3. Click install for the Less module.

API usage


Compile string and two .less files to a css file

$less = $modules->get('Less');
$less->setOption('compress', true);
$less->addStr('@color: #4D926F; h2 { color: @color; }');
$less->addFile('/path/to/file1.less');
$less->addFile('/path/to/file2.less', '/url/to/images/');
$less->saveCss('/path/to/file.min.css');

Access Wikimedia less parser directly

$parser = $less->parser();
$parser->parseFile('/path/to/file.less');
$css = $parser->getCss();

For details about API methods you can access from $parser see: https://github.com/wikimedia/less.php/blob/v4.1.1/API.md

Usage with ProcessWire’s AdminThemeUikit module


Install this module to add the ability to customize the ProcessWire core AdminThemeUikit admin theme module CSS. For this usage, you must have ProcessWire 3.0.179 or newer. See instructions here: https://processwire.com/blog/posts/pw-3.0.179/

License


This module uses the Apache license for consistency with the Wikimedia LESS parser license.

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #549
    In the 549th issue of ProcessWire Weekly we’re going to check out the latest core updates, highlight one older yet still very relevant third party module, and more. Read on!
    Weekly.pw / 17 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH