Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:oyejorge/less.php
Browse files Browse the repository at this point in the history
  • Loading branch information
oyejorge committed Sep 24, 2013
2 parents 62284d9 + 97c96ea commit 5f7a60b
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,29 @@ $css = $parser->getCss();
```


### Getting Info About The Parsed Files
php.less can tell you which .less files were imported and parsed.
### Caching CSS
Use the Less_Cache class to save and reuse the results of compiled less files.
This method we check the modified time of each less file (including imported files) and regenerate when changes are found.
Note: When changes are found, this method will return a different file name for the new cached content.

```php
<?php
$parser = new \Less\Parser();
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
$imported_files = $parser->allParsedFiles();
$to_cache = array( '/var/www/mysite/bootstrap.less' => '/mysite/' );
Less_Cache::$cache_dir = '/var/www/writable_folder';
$css_file_name = Less_Cache::Get( $to_cache );
$compiled = file_get_contents( '/var/www/writable_folder/'.$css_file_name );
```


### Caching to Improve Performance
php.less 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 php.less.
### Getting Info About The Parsed Files
php.less can tell you which .less files were imported and parsed.

```php
<?php
$parser = new \Less\Parser();
$parser->SetCacheDir( '/var/www/writable_folder' );
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
$imported_files = $parser->allParsedFiles();
```


Expand Down Expand Up @@ -114,6 +114,20 @@ $css = $parser->getCss();
```


### Parser Caching
php.less 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 php.less.

```php
<?php
$parser = new \Less\Parser();
$parser->SetCacheDir( '/var/www/writable_folder' );
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
$css = $parser->getCss();
```


credits
---
php.less was originally ported to php by [Matt Agar](https://github.com/agar) and then updated by [Martin Jantošovič](https://github.com/Mordred).
Expand Down

0 comments on commit 5f7a60b

Please sign in to comment.