I had a similar problem earlier, when I tried to run grunt from inside a PHP script. It turned out, the problem was the missing environment variables.
So if you could execute your sass command in the bash, but it doesn't work from inside the php script, the following could help you solve your problem.
To list your current environment vars, you could use the unix command printenv
. This should give you a list like the following
LANG=en_US.UTF-8
rvm_bin_path=/usr/local/rvm/bin
rvm_version=1.26.11 (latest)
RUBY_VERSION=ruby-2.2.1
GEM_HOME=/usr/local/rvm/gems/ruby-2.2.1
...
As scss uses ruby, it is important to have all the ruby env vars available. So you could pick everything you need from printenvs output and write it inside an array.
$env = [
"LANG" => "en_US.UTF-8",
"rvm_bin_path" => "/usr/local/rvm/bin",
...
];
$env_command = '';
foreach ($env as $var => $value) {
$env_command .= "$var=$value ";
}
$command = "/usr/local/bin/sass ...";
exec "$env_command $command";
I'm not sure, which vars are actual important - so you have to figure this out on your own.