0

Is it possible to override existing variables from the LESSPHP compiler e.g.

$less = new lessc;

$less->setVariables(array(
  "color" => "red",
  "base" => "960px"
));

echo $less->compileFile('source.less','destination.css');

where source.less already has the @color and @base variables present. If not is there another approach i can do to achieve this?

AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
  • You can try to [`unsetVariable`](http://leafo.net/lessphp/docs/#setting_variables_from_php) before setting it (I dont't know if this works though). As for other options, well, taking into account that lessphp is no longer developed you can consider to switch to [less.php](http://lessphp.gpeasy.com/) which provides up-to-date Less implementation (and also has the `ModifyVars` method that does what you need). – seven-phases-max Feb 25 '14 at 12:05

1 Answers1

0

This is actually a bug in the LessPHP compiler. I would recommend avoiding the PHP version of the compiler as the owner doesn't seem to be maintaining the project (at least not fast enough for me), and use the official node compiler.

LessPHP can be patched, though I don't know if it's 100%: https://github.com/ldbglobe/lessphp/compare/patch-1

You can see all the +1's to correct this issue here: https://github.com/leafo/lessphp/issues/302

Personally I'm moving to the official node compiler, as this is core functionality of Less, as is very important feature. Also by using the official compiler, you're sure that features are implemented as intended.

Justin Fortier
  • 451
  • 5
  • 6