rsymfonypathsymfony2

Executing R scripts in Symfony2


I have to execute (safely) a lot of R scripts from a Symfony2 controller. I organized in my AcmeStatsBundle a folder named RScripts. There, a lot of R script files are stored, e.g. Test.R To execute the script in the Test.R file, I should write in my secured action something like:

$rootdir = ...//get the path to the src folder.
exec("Rscript $rootdir/Acme/StatsBundle/RScripts/Test.R");

Which is the command to use to get the right value for $rootdir? Maybe I'm wrong and I should deploy the scripts in the app folder. Where should I put the generated output (e.g. images), in the web folder?


Solution

  • Should be :

    $rootdir = $this->get('kernel')->getRootDir() . '\..\src'
    

    (what's those '\' is that some windows thing ?)