There are two LessCSS compilers in PHP that I am aware of:
Both claim to be compatible with Bootstrap (version 3). However I am struggling to get anything going given the steep learning curve of these three facets. In short, I just want to achieve the following:
Compile multiple .less files together in PHP:
- bootstrap.less
- my.less
Compiling a single file in leafo.net/lessphp
was easy, I found:
require_once 'lessc.inc.php';
$less = new lessc;
$less->checkedCompile("my.less", "mainless.css");
However I am not sure if the library is designed for multiple files. (If so, how could/should it be done?)
I decided to move on to a different library which explicitly demonstrated how to compile for bootstrap: lessphp.gpeasy.com
. However their example snippet has left me scratching my head (taken from here):
<?php
require 'less.php/LessCache.php';
$files = 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 );
After looking at their other examples, I realised that $files
and $to_cache
were a typo: they are meant to be the same variable. But after reading documentation and looking at source I gave up trying to work out if the following strings were accurately conveying their purpose:
/var/www/mysite/bootstrap.less
- Is this the less file to be compiled?/mysite/
- what is this for??/var/www/writable_folder
- Is this where the css is written to?
Please could someone give me a snippet that would compile bootstrap.less
and my.less
into css file(s) using PHP?