title: Compiling Less CSS for Bootstrap 3 with PHP
body: <p>There are two LessCSS compilers in PHP that I am aware of:</p>
  
  <ul>
  <li><a href="http://leafo.net/lessphp/" rel="noreferrer">http://leafo.net/lessphp/</a></li>
  <li><a href="http://lessphp.gpeasy.com/" rel="noreferrer">http://lessphp.gpeasy.com/</a></li>
  </ul>
  
  <p>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:</p>
  
  <p><strong>Compile multiple .less files together in PHP:</strong></p>
  
  <ol>
  <li><strong>bootstrap.less</strong></li>
  <li><strong>my.less</strong></li>
  </ol>
  
  <p>Compiling a single file in <code>leafo.net/lessphp</code> was easy, I found:</p>
  
  <pre><code>require_once 'lessc.inc.php'; 
  $less = new lessc;
  $less-&gt;checkedCompile("my.less", "mainless.css");
  </code></pre>
  
  <p>However I am not sure if the library is designed for multiple files. (If so, how could/should it be done?)</p>
  
  <p>I decided to move on to a different library which explicitly demonstrated how to compile for bootstrap: <code>lessphp.gpeasy.com</code>. However their example snippet has left me scratching my head (taken from <a href="http://lessphp.gpeasy.com/Bootstrap" rel="noreferrer">here</a>):</p>
  
  <pre><code>&lt;?php
  require 'less.php/LessCache.php';
  $files = array( '/var/www/mysite/bootstrap.less' =&gt; '/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 );
  </code></pre>
  
  <p>After looking at their other examples, I realised that <code>$files</code> and <code>$to_cache</code> 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:</p>
  
  <ol>
  <li><code>/var/www/mysite/bootstrap.less</code> - Is this the less file to be compiled?</li>
  <li><code>/mysite/</code> - what is this for??</li>
  <li><code>/var/www/writable_folder</code> - Is this where the css is written to?</li>
  </ol>
  
  <p>Please could someone give me a snippet that would <strong>compile <code>bootstrap.less</code> and <code>my.less</code> into css file(s)</strong> using PHP?</p>