title: How can I execute the LESS compiler from PHP (using Symfony)?
body: <p>I'm having trouble executing the lessc compiler from PHP. I'm using Symfony, and have tried using the sfLESSPlugin, but have been unsuccessful. I've put my code in a filter that executes before the page renders, so that every time the page is refreshed, my LESS files are compiled into one CSS file (don't want to have recompile manually every time I make a change, at least while I'm developing). Here are the different variations that I've attempted:</p>
  
  <pre><code>$fs = new sfFilesystem();
  $command = '/Users/jordanb/node/node_modules/less/bin/lessc less/bootstrap.less css/bootstrap.css';
  
  try
  {
    $fs-&gt;execute($command, null, array($this, 'throwCompilerError'));
  }
  catch (RuntimeException $e)
  {
    return false;
  }
  </code></pre>
  
  <p>This returns an error: "Problem executing command", with an error code of 127. Digging deeper into Symfony's execute(), it calls proc_open() and then proc_close(). Some research online told me that an error code of 127 means that the command was not found.</p>
  
  <p>Running the <strong>exact same command</strong> on the command line works just fine.</p>
  
  <p>To be extra sure, I executed chmod 777 on /Users/jordanb/node/node_modules/less/bin/lessc, just to make sure it wasn't a permissions issue. Still didn't work.</p>
  
  <p>I also tried just "lessc" instead of the full path, which didn't work. I've added lessc to my classpath, so typing "which lessc" gives me "/Users/jordanb/node/node_modules/less/bin/lessc".</p>
  
  <p>I also tried a simple:</p>
  
  <pre><code>shell_exec('lessc less/bootstrap.less css/bootstrap.css');
  </code></pre>
  
  <p>which didn't seem to do anything. I printed the output to the PHP error log as well as to a text file, and the output was empty in both cases. I also tried using the full path in this case.</p>