项目作者: kylekatarnls

项目描述 :
PHP wrapper to execute less node package or fallback to a PHP alternative.
高级语言: PHP
项目地址: git://github.com/kylekatarnls/less.git
创建时间: 2016-07-28T21:38:51Z
项目社区:https://github.com/kylekatarnls/less

开源协议:MIT License

下载


less

Latest Stable Version
Build Status
StyleCI
Test Coverage
Code Climate

PHP wrapper to execute less node package or fallback to a PHP alternative.

Usage

First you need composer if you have not already. Then get the package with composer require nodejs-php-fallback/less then require the composer autload in your PHP file if it’s not already:

  1. <?php
  2. use NodejsPhpFallback\Less;
  3. // Require the composer autoload in your PHP file if it's not already.
  4. // You do not need to if you use a framework with composer like Symfony, Laravel, etc.
  5. require 'vendor/autoload.php';
  6. $less = new Less('path/to/my-less-file.less');
  7. // Output to a file:
  8. $less->write('path/to/my-css-file.css');
  9. // Get CSS contents:
  10. $cssContents = $less->getResult();
  11. // Output to the browser:
  12. header('Content-type: text/css');
  13. echo $less;
  14. // You can also get less code from a string:
  15. $less = new Less('
  16. a {
  17. color: blue;
  18. &:hover {
  19. color: navy;
  20. }
  21. }
  22. ');
  23. // Then write CSS with:
  24. $less->write('path/to/my-css-file.css');
  25. // or get it with:
  26. $cssContents = $less->getResult();
  27. // Pass true to the less constructor to minify the rendered CSS:
  28. $less = new Less('path/to/my-less-file.styl', true);