0

I am trying to execute sass --update via PHP shell_exec() function and get an error:

H:\SERVER\htdocs\path\to\project>sass --style compressed --update sass\:deployment\css\ 'sass' is not recognized as an internal or external command, operable program or batch file. 

If I run the same command from the cmd manually - it works fine. The current folder is correct - checked with the getcwd()

1 Answers1

1

When you run the command sass in a shell, your computer has to find the executable program called sass somewhere on your computer. To do this, it looks through a series of folders called your PATH. Your PHP server is most likely running with a different PATH than your command prompt, and as such, is not able to find the executable.

To fix this: From your command prompt, where sass DOES work, run this command: which sass (on Windows, instead use where sass)

That will tell you the exact location of sass (for example, it might be /usr/bin/sass or something like that). Once you have that value, replace "sass" in your PHP code with that entire location.

Hayden Schiff
  • 3,007
  • 15
  • 36