2

I am trying to compile less file using php, and I am trying to use lessc which I installed as nodejs module on my windows 7

I am trying to do :

$command = lessc %s -compress %s 

via

exec($command, $output);

and if I do this via cmd it works fine but I can't execute it using above command in php :(.

the path which works are relative to my drive (E:/wamp/my-project/less/hello.less)

Any body knows what I am doing wrong?

Note: I know how I can use lessphp compiler, and I am already using it but I would like to use lessc module installed via nodejs.

Syed
  • 148
  • 1
  • 16

1 Answers1

0

Are you able to get the output of the command when it fails? It's possible that lessc isn't directly available in your path. If you installed it via npm install -g then it will likely be in %appdata%, which is a user path'd directory. It really depends upon how the php process gets initiated, but my guess is that this path won't work.

If I need to use an npm module like this, I usually npm install it locally, and invoke the path to lessc.cmd from a relative path to my program.

Hope this helps. Happy coding!

Justin Beckwith
  • 7,686
  • 1
  • 33
  • 55
  • Thanks Justin, I haven't digged it again yet, will give it another go in coming weeks, as I am starting to have issues with lessphp (its not a clone of less.js, so :(). Will let you know if it works or not. – Syed Nov 08 '13 at 13:27