Having some issues integrating PHP and R. I am working from this article:
http://www.r-bloggers.com/integrating-php-and-r/
R is installed and is verified working with our R script:
Rscript C:\inetpub\wwwroot\client\includes\decisionTreePredictor.R 20 10 O 1000 10000 5000 0.2 10.2
Printing a single value that is a result of its calculations:
[1] "0"
(The path to Rscript.exe is set in the Windows environmental variables)
I have a PHP script in place that is using exec() which tests successfully with commands such as:
$result = exec('dir',$output,$returnVar);
echo "<br>result ". print_r($result,true);
echo "<br>output <pre>". print_r($output,true) , "</pre>";
echo "<br>return ". print_r($returnVar,true);
returning:
result 2 Dir(s) 117,749,354,496 bytes free
output
Array
(
[0] => Volume in drive C is C_DRIVE
[1] => Volume Serial Number is 7EB2-A074
[2] =>
[3] => Directory of C:\inetpub\wwwroot\client\temp
[4] =>
[5] => 05/17/2014 10:29 PM .
[6] => 05/17/2014 10:29 PM ..
[7] => 05/16/2014 09:24 AM 5,181 dbimporttest.php
[8] => 05/17/2014 10:29 PM 0 routput.txt
[9] => 05/17/2014 11:42 PM 701 rscripttest.php
[10] => 05/16/2014 04:59 PM 425 whoami.php
[11] => 4 File(s) 6,307 bytes
[12] => 2 Dir(s) 117,749,354,496 bytes free
)
return 0
When I try to run the R script within the exec command, it fails:
$result = exec('Rscript.exe C:\inetpub\wwwroot\client\includes\decisionTreePredictor.R 20 10 O 1000 10000 5000 0.2 10.2',$output,$returnVar);
echo "<br>result ". print_r($result,true);
echo "<br>output <pre>". print_r($output,true) , "</pre>";
echo "<br>return ". print_r($returnVar,true);
Returning:
result
output
Array
(
)
return 1
I am running:
- Windows Server 8 R2
- IIS 8
- PHP 5.5
- R 3.1