PHP port of the LESS processor
Installs: 12 541 333
Open Issues: 12
- php: >=7.4.3
- mediawiki/mediawiki-codesniffer: 41.0.0
- mediawiki/mediawiki-phan-config: 0.12.0
- mediawiki/minus-x: 1.1.1
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpunit/phpunit: 9.5.28
This package is auto-updated.
Last update: 2023-05-17 20:42:34 UTC
This is a PHP port of the official LESS processor.
- API § Caching, Less.php includes a file-based cache.
- API § Source maps, Less.php supports v3 sourcemaps.
- API § Command line, the
lessccommand includes a watch mode.
You can install the library with Composer or standalone.
If you have Composer installed:
composer require wikimedia/less.php
Less_Parserin your code.
- Download Less.php and upload the PHP files to your server.
- Include the library:
require_once '[path to]/less.php/lib/Less/Autoloader.php'; Less_Autoloader::register();
Less_Parserin your code.
The LESS processor language is powerful and includes features that may read or embed arbitrary files that the web server has access to, and features that may be computationally exensive if misused.
In general you should treat LESS files as being in the same trust domain as other server-side executables, such as PHP code. In particular, it is not recommended to allow people that use your web service to provide arbitrary LESS code for server-side processing.
See also SECURITY.
Who uses Less.php?
- Wikipedia and the MediaWiki platform (docs).
- Matomo (docs).
- Magento as part of Adobe Commerce (docs).
- Icinga in Icinga Web (docs).
- Shopware (docs).
Less.php has been integrated with various other projects.
Transitioning from Leafo/lessphp
If you're looking to transition from the Leafo/lessphp library, use the
lessc.inc.php adapter file that comes with Less.php.
This allows Less.php to be a drop-in replacement for Leafo/lessphp.
Download Less.php, unzip the files into your project, and include its
setPreserveComments option is ignored. Less.php already preserves CSS block comments by default, and removes LESS inline comments.
Less.php can be used with Drupal's less module via the
lessc.inc.php adapter. Download Less.php and unzip it so that
lessc.inc.php is located at
sites/all/libraries/lessphp/lessc.inc.php, then install the Drupal less module as usual.
- wp_enqueue_less is a Composer package for use in WordPress themes and plugins. It provides a
wp_enqueue_less()function to automatically manage caching and compilation on-demand, and loads the compressed CSS on the page.
- JBST framework bundles a copy of Less.php.
- The lessphp plugin bundles a copy of Less.php for use in other plugins or themes. This dependency can also be combined with the TGM Library.
Less.php was originally ported to PHP in 2011 by Matt Agar and then updated by Martin Jantošovič in 2012. From 2013 to 2017, Josh Schmidt lead development of the library. Since 2019, the library is maintained by Wikimedia Foundation.