项目作者: JBZoo

项目描述 :
PHP wrapper for wikimedia/less.php.
高级语言: PHP
项目地址: git://github.com/JBZoo/Less.git
创建时间: 2016-02-22T11:56:53Z
项目社区:https://github.com/JBZoo/Less

开源协议:MIT License

下载


JBZoo / Less

CI Coverage Status Psalm Coverage Psalm Level CodeFactor
Stable Version Total Downloads Dependents GitHub License

PHP wrapper for wikimedia/less.php.

Install

  1. composer require jbzoo/less

Usage

  1. use JBZoo\Less\Less;
  2. try { // Any error handling
  3. // There is not option required
  4. $less = new Less([
  5. 'force' => false, // Can forced compile on each compile() calling
  6. 'debug' => false, // On/Off Source map for browser debug console
  7. 'root_url' => 'http://site.com/', // Root URL for all CSS files and debug mode
  8. // For example - background:url('http://site.com/image.png')
  9. 'root_path' => '/full/path/to/site', // Full path to root of web directory
  10. 'global_vars' => [ // Some vars that will be in all less files
  11. 'color' => '#f00', // @color: #f00;
  12. 'media' => 'print', // @media: print;
  13. ],
  14. 'autoload' => [ // Autoload before eash compiling
  15. '/full/path/to/my_mixins.less', // See the best of collection here
  16. ], // https://github.com/JBZoo/JBlank/tree/master/less/misc
  17. 'import_paths' => [ // Import paths
  18. '/full/path/to/assets/less/' => 'http://site.com/assets/less/',
  19. './or/relative/path/to/dir/' => './or/relative/path/to/dir/',
  20. ],
  21. 'cache_path' => './cache', // Where JBZoo/Less will save compiled CSS-files
  22. 'cache_ttl' => 2592000, // How often rebuild css files (in seconds)
  23. 'functions' => [ // Custom functions for less (only for gpeasy!)
  24. 'str-revert' => function ($arg) { // Register name `str-revert()`
  25. $arg->value = strrev($arg->value); // Just revert argument
  26. return $arg; // Result: str-revert('1234567890'); => '0987654321';
  27. },
  28. ],
  29. ]);
  30. $less->setImportPath(
  31. '/full/path/to/other/import/directory/', // Full or relative path
  32. 'http://site.com/other/import/directory/' // Not required
  33. );
  34. $fullCSSpath_1 = $less->compile('/full/path/to/styles.less'); // Basepath from config
  35. $fullCSSpath_2 = $less->compile('./relative/path/to/styles.less'); // OR relative path
  36. $fullCSSpath_3 = $less->compile(
  37. './relative/path/to/styles.less',
  38. 'http://site.com/relative/path/to/' // Force base path for any URLs
  39. );
  40. } catch (JBZoo\Less\Exception $e) {
  41. echo 'JBZoo/Less: ' . $e->getMessage();
  42. }

Unit tests and check code style

  1. make update
  2. make test-all

License

MIT