I am using the following code to run the function in background.
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null 2>&1 &");
}
}
$cmd = execInBackground("http://example.com/parentdesc/frontend/web/index.php?r=site%2Ftest");
It is working fine. But how can I pass the parameters to the exec?
I tried:
$cmd = execInBackground("http://example.com/parentdesc/frontend/web/index.php?r=site%2Ftest \"param1\" \"param2\" ");
And in my function I print the $argv. But it doesn't have any values in it.
My function:
public function actionTest()
{
// does not have anything
print_r($argv);
// here is my mail sending logic
}
Am I missing something?