Composer is a dependency management system for PHP packages. This patch adds Composer support to the LESS module. Having this means that the module can specify the following in its composer.json to depict a dependency on LessPHP:
"require": {
"leafo/lessphp": "0.3.5"
}
Once this patch is committed, using the Composer Drush integration makes installing the LESS module VERY easy, as the LessPHP library is installed for you.
$ drush dl composer
$ drush dl less
The LESS module now has a vendor directory with LessPHP in it. The _less_inc() function will register the lessc class to be autoloaded when needed.
To test out composer.json, you can run the following:
$ drush dl composer
$ drush composer install
It will download LessPHP and set up autoload.php for you. Attached is a screenshot of it running on the Symfony and xCSS modules.
Note: This patch does not remove the Libraries API support to LESS. It just adds support for you to use Composer to handle LessPHP instead of Libraries. If you still want to use Libraries module, that still works just fine.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | less-composer.png | 33.42 KB | robloach |
| composer.patch | 2.98 KB | robloach | |
| drushdl.png | 89 KB | robloach |
Comments
Comment #1
corey.aufang commentedAfter looking at your patch, this is what I came up with:
Forcing an auto-load to check for class presence at this point is not a problem since the only time that _less_inc() is called is immediately before compiling a file or on the Drupal status report.
Also, I had to run "drush composer install" form the LESS module directory, which seems to counter intuitive when dealing with Drush. Is this a bug?
Comment #2
robloachThat looks great!
It's not require to do this once
composer.jsonis committed and in a release. A composer installation is run whendrush dl lessis executed when it finds a composer.json file.We've also been playing around with the idea of a #1452984: drush composer-mass install, which would go though each module and run a composer install from all their directories. Would love your thoughts on that.
Comment #3
corey.aufang commentedThis should be in the latest dev.
Will be pushing new version soon.
Comment #4
corey.aufang commentedForgot to mark as mixed.
Comment #5
robloachmixed indeed!
Comment #6
robloachThanks a lot! It's working :-) .