I am trying to run a couple commands from PHP with exec() and it seems to work only for some of the commands defined in my windows environment variables but not for all.
In my command prompt I can run all of this commands succesfully from any path (C:\ or E:\whatever)
> pear -V // ... "PEAR Version: 1.9.5" ...
> dot -V // dot - graphviz version 2.38.0 (20140413.2041)
> phpdoc -V // phpDocumentor version 2.8.1
All of them return the correct version for each of the specified programs, that means that the environment variables are well configured.
But in PHP I can only run some commands, the rest of them fails:
$out = array();
$ret = '';
exec('pear -V', $out, $ret);
echo var_dump($out); // $ret = 0, $out = array ..."PEAR Version: 1.9.5" ...
exec('phpdoc -V', $out, $ret);
echo var_dump($out); // $ret = 1, $out = array ..."Could not open input file: \phpdoc" ...
exec('dot -V', $out, $ret);
echo var_dump($out); // $ret = 1, $out = empty array
So, am I missing something?.
EDIT: exec() is working fine, it works for some of my environment variables like pear, cmd, among others, it does not work for the specified above
phpdoc
dot (GraphViz)
Even though they work on my command prompt and are well configured in my windows environment.
EDIT2:
@Stefan Cvetkovic
I gues this is the part that you want to see from the result when running this command
shell_exec("set"):
Path=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\Universal Extractor;C:\Program Files (x86)\Universal Extractor\bin;C:\xampp\php; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Is it possible that php has no access to my "dot" path, because this is missing from that result:
...C:\xampp\php;C:\xampp\php\pear\phpDocumentor\vendor\graphviz\bin
dot.exe is located in C:\xampp\php\pear\phpDocumentor\vendor\graphviz\bin and it is well configured as I can run > dot -V from my command prompt.
I have also tried changing its position in the PATH variable without luck.
exec()be disabled by safe mode? Have you set the safe mode off?