[Less.php](http://lessphp.typesettercms.com)
========
This is the Wikimedia fork of a PHP port of the official LESS processor <http://lesscss.org>. [![Build Status](https://travis-ci.org/wikimedia/less.php.png?branch=master)](https://travis-ci.org/wikimedia/less.php)
* [About](#about)
* [Installation](#installation)
* [Basic Use](#basic-use)
* [Caching](#caching)
* [Source Maps](#source-maps)
* [Command Line](#command-line)
* [Integration with other projects](#integration-with-other-projects)
* [Transitioning from Leafo/lessphp](#transitioning-from-leafolessphp)
* [Credits](#credits)
About
---
The code structure of less.php mirrors that of the official processor which helps us ensure compatibility and allows for easy maintenance.
Please note, there are a few unsupported LESS features:
- Evaluation of JavaScript expressions within back-ticks (for obvious reasons).
- Definition of custom functions.
Installation
---
You can install the library with Composer or manually.
#### Composer
Step 1. Edit your `composer.json`:
```json
{
"require": {
"wikimedia/less.php": "~1.7.0.9"
}
}
```
Step 2. Install it:
```bash
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
```
#### Manually From Release
Step 1. [Download the latest release](https://github.com/wikimedia/less.php/releases) and upload the PHP files to your server.
Step 2. Include the library:
```php
require_once '[path to less.php]/Less.php';
```
#### Manually From Source
Step 1. [Download the source](https://github.com/wikimedia/less.php/archive/master.zip) and upload the files in /lib/Less to a folder on your server.
Step 2. Include the library and register the autoloader
```php
require_once '[path to less.php]/Autoloader.php';
Less_Autoloader::register();
```
Basic Use
---
#### Parsing Strings
```php
$parser = new Less_Parser();
$parser->parse( '@color: #4D926F; #header { color: @color; } h2 { color: @color; }' );
$css = $parser->getCss();
```
#### Parsing LESS Files
The parseFile() function takes two arguments:
1. The absolute path of the .less file to be parsed
2. The url root to prepend to any relative image or @import urls in the .less file.
```php
$parser = new Less_Parser();
$parser->parseFile( '/var/www/mysite/bootstrap.less', 'http://example.com/mysite/' );
$css = $parser->getCss();
```
#### Handling Invalid LESS
An exception will be thrown if the compiler encounters invalid LESS.
```php
try{
$parser = new Less_Parser();
$parser->parseFile( '/var/www/mysite/bootstrap.less', 'http://example.com/mysite/' );
$css = $parser->getCss();
}catch(Exception $e){
$error_message = $e->getMessage();
}
```
#### Parsing Multiple Sources
less.php can parse multiple sources to generate a single CSS file.
```php
$parser = new Less_Parser();
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$parser->parse( '@color: #4D926F; #header { color: @color; } h2 { color: @color; }' );
$css = $parser->getCss();
```
#### Getting Info About The Parsed Files
less.php can tell you which .less files were imported and parsed.
```php
$parser = new Less_Parser();
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
$imported_files = $parser->allParsedFiles();
```
#### Compressing Output
You can tell less.php to remove comments and whitespace to generate minimized CSS files.
```php
$options = array( 'compress'=>true );
$parser = new Less_Parser( $options );
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
```
#### Getting Variables
You can use the getVariables() method to get an all variables defined and
their value in a php associative array. Note that LESS has to be previously
compiled.
```php
$parser = new Less_Parser;
$parser->parseFile( '/var/www/mysite/bootstrap.less');
$css = $parser->getCss();
$variables = $parser->getVariables();
```
#### Setting Variables
You can use the ModifyVars() method to customize your CSS if you have variables stored in PHP associative arrays.
```php
$parser = new Less_Parser();
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$parser->ModifyVars( array('font-size-base'=>'16px') );
$css = $parser->getCss();
```
#### Import Directories
By default, less.php will look for @imports in the directory of the file passed to parseFile().
If you're using parse() or if @imports reside in different directories, you can tell less.php where to look.
```php
$directories = array( '/var/www/mysite/bootstrap/' => '/mysite/bootstrap/' );
$parser = new Less_Parser();
$parser->SetImportDirs( $directories );
$parser->parseFile( '/var/www/mysite/theme.less', '/mysite/' );
$css = $parser->getCss();
```
Caching
---
Compiling LESS code into CSS is a time consuming process, caching your results is highly recommended.
#### Caching CSS
Use the Less_Cache class to save and reuse the results of compiled LESS files.
This method will check the modified time and size of each LESS file (including imported files) and regenerate a new CSS file when changes are found.
Note: When changes are found, this method will return a different file name for the new cached content.
```php
$less_files = array( '/var/www/mysite/bootstrap.less' => '/mysite/' );
$options = array( 'cache_dir' => '/var/www/writable_folder' );
$css_file_name = Less_Cache::Get( $less_files, $options );
$compiled = file_get_contents( '/var/www/writable_folder/'.$css_file_name );
```
#### Caching CSS With Variables
Passing options to Less_Cache::Get()
```php
$less_files = array( '/var/www/mysite/bootstrap.less' => '/mysite/' );
$options = array( 'cache_dir' => '/var/www/writable_folder' );
$variables = array( 'width' => '100px' );
$css_file_name = Less_Cache::Get( $less_files, $options, $variables );
$compiled = file_get_contents( '/var/www/writable_folder/'.$css_file_name );
```
#### Parser Caching
less.php will save serialized parser data for each .less file if a writable folder is passed to the SetCacheDir() method.
Note: This feature only caches intermediate parsing results to improve the performance of repeated CSS generation.
Your application should cache any CSS generated by less.php.
```php
$options = array('cache_dir'=>'/var/www/writable_folder');
$parser = new Less_Parser( $options );
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
```
You can specify the caching technique used by changing the ```cache_method``` option. Supported methods are:
* ```php```: Creates valid PHP files which can be included without any changes (default method).
* ```var_export```: Like "php", but using PHP's ```var_export()``` function without any optimizations.
It's recommended to use "php" instead.
* ```serialize```: Faster, but pretty memory-intense.
* ```callback```: Use custom callback functions to implement your own caching method. Give the "cache_callback_get" and
"cache_callback_set" options with callables (see PHP's ```call_user_func()``` and ```is_callable()``` functions). less.php
will pass the parser object (class ```Less_Parser```), the path to the parsed .less file ("/some/path/to/file.less") and
an identifier that will change every time the .less file is modified. The ```get``` callback must return the ruleset
(an array with ```Less_Tree``` objects) provided as fourth parameter of the ```set``` callback. If something goes wrong,
return ```NULL``` (cache doesn't exist) or ```FALSE```.
Source Maps
---
Less.php supports v3 sourcemaps
#### Inline
The sourcemap will be appended to the generated CSS file.
```php
$options = array( 'sourceMap' => true );
$parser = new Less_Parser($options);
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
```
#### Saving to Map File
```php
$options = array(
'sourceMap' => true,
'sourceMapWriteTo' => '/var/www/mysite/writable_folder/filename.map',
'sourceMapURL' => '/mysite/writable_folder/filename.map',
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v2.3.1 nulled.zip
共338个文件
php:260个
js:26个
mo:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 147 浏览量
2022-04-04
16:32:40
上传
评论
收藏 1.6MB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v2.3.1 nulled Advanced Scripts by Clean Plugins Clean插件的高级脚本" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v2.3.1 nulled.zip (338个子文件)
ScriptsManager.php.bak 39KB
functions.php.bak 2KB
lessc.bat 122B
pscss.bat 119B
Less.php.combine 226B
style.min.css 73KB
dialog-boxes.css 13KB
add-ons.css 12KB
connect.css 10KB
common.css 5KB
account.css 5KB
customizer.css 3KB
affiliation.css 2KB
debug.css 657B
plugins.css 514B
gdpr-optin-notice.css 323B
checkout.css 83B
phpcs.xml.dist 379B
mode-php.js 462KB
ace.js 353KB
script.min.js 275KB
emmet.js 213KB
worker-html.js 193KB
worker-javascript.js 149KB
worker-css.js 127KB
worker-php.js 66KB
mode-html.js 59KB
ext-language_tools.js 36KB
ext-emmet.js 24KB
mode-scss.js 23KB
mode-less.js 22KB
mode-css.js 20KB
worker-base.js 20KB
css.js 20KB
html.js 19KB
mode-javascript.js 18KB
ext-searchbox.js 11KB
php.js 7KB
nojquery.ba-postmessage.js 5KB
postmessage.js 4KB
javascript.js 4KB
nojquery.ba-postmessage.min.js 1KB
less.js 128B
scss.js 128B
installed.json 7KB
composer.json 4KB
composer.json 761B
lessc 4KB
lessc 641B
LICENSE 9KB
LICENSE 1KB
README.md 11KB
README.md 3KB
CHANGES.md 2KB
LICENSE.md 1KB
freemius-ta.mo 91KB
freemius-ru_RU.mo 74KB
freemius-ja.mo 66KB
freemius-fr_FR.mo 62KB
freemius-es_ES.mo 61KB
freemius-he_IL.mo 61KB
freemius-it_IT.mo 60KB
freemius-nl_NL.mo 60KB
freemius-cs_CZ.mo 60KB
freemius-hu_HU.mo 59KB
freemius-da_DK.mo 58KB
freemius-en.mo 58KB
freemius-zh_CN.mo 55KB
class-freemius.php 956KB
Compiler.php 296KB
Parser.php 110KB
fs-plugin-info-dialog.php 79KB
Parser.php 64KB
account.php 64KB
class-fs-plugin-updater.php 61KB
i18n.php 51KB
fs-core-functions.php 49KB
connect.php 44KB
ScriptsManager.php 39KB
Functions.php 37KB
debug.php 34KB
license-activation.php 34KB
ConditionManager.php 29KB
affiliation.php 29KB
class-fs-admin-menu-manager.php 26KB
add-ons.php 23KB
addon.php 22KB
Number.php 21KB
FreemiusWordPress.php 20KB
class-fs-storage.php 20KB
site.php 20KB
form.php 20KB
main.php 19KB
class-fs-api.php 19KB
start.php 19KB
class-fs-logger.php 17KB
class-fs-admin-notice-manager.php 17KB
class-fs-options.php 17KB
Ruleset.php 16KB
ClassLoader.php 16KB
共 338 条
- 1
- 2
- 3
- 4
资源评论
Lee达森
- 粉丝: 957
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功