wikimedia / less.php
PHP port of the LESS processor
Installs: 19 898 239
Dependents: 63
Suggesters: 5
Security: 0
Stars: 111
Watchers: 19
Forks: 195
Open Issues: 11
Requires
- php: >=7.4.3
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 45.0.0
- mediawiki/mediawiki-phan-config: 0.14.0
- mediawiki/minus-x: 1.1.3
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: 9.6.16
- dev-master
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.0
- v4.4.1
- 4.4.0
- v4.3.0
- v4.2.1
- v4.2.0
- v4.1.1
- v4.1.0
- v4.0.0
- v3.2.1
- v3.2.0
- v3.1.0
- v3.0.0
- v2.0.0
- 1.8.2
- 1.8.1
- v1.8.0
- v1.7.0.14
- v1.7.0.13
- v1.7.0.12
- v1.7.0.11
- v1.7.0.10
- v1.7.0.9
- v1.7.0.8
- v1.7.0.7
- v1.7.0.6
- v1.7.0.5
- v1.7.0.4
- v1.7.0.3
- v1.7.0.2
- v1.7.0.1
- v1.7.0
- v1.6.3.1
- v1.6.3
- v1.6.1
- v1.6.1rc2
- v1.6.1rc1
- v1.5.1.2
- v1.5.1.1
- v1.5.1
- v1.5.1rc3
- v1.5.1rc2
- v1.5.1rc1
- v1.5.1b2
- v1.5.1b1
- v1.4.2.2
- v1.4.2.1
- v1.4.2
- v1.4.2rc1
- v1.4.2b3
- 1.4.2b2
- v1.3.0
This package is auto-updated.
Last update: 2024-11-18 20:03:02 UTC
README
Less.php
This is a PHP port of the official LESS processor.
About
The code structure of Less.php mirrors that of upstream Less.js to ensure compatibility and help reduce maintenance. The port aims to be compatible with Less.js 3.13.1. Please note that "inline JavaScript expressions" (via eval or backticks) are not supported.
- API § Caching, Less.php includes a file-based cache.
- API § Source maps, Less.php supports v3 sourcemaps.
- API § Command line, the
lessc
command includes a watch mode.
Installation
You can install the library with Composer or standalone.
If you have Composer installed:
- Run
composer require wikimedia/less.php
- Use
Less_Parser
in your code.
Or standalone:
- 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();
- Use
Less_Parser
in your code.
Security
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).
- Winter CMS (docs)
Integrations
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 lessc.inc.php
instead.
Note: The setPreserveComments
option is ignored. Less.php already preserves CSS block comments by default, and removes LESS inline comments.
Drupal
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.
WordPress
- 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.
Credits
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.
Contribute
- Issue tracker: https://phabricator.wikimedia.org/tag/less.php/
- Source code: https://gerrit.wikimedia.org/g/mediawiki/libs/less.php (Get started with Gerrit)