What I need to do : I need to launch three commands from an index.php file in the navigator in a shell without blocking the navigator on each command but each command need to wait for the previous one to finish to be able to start.
What I tried (used the first note from this link http://php.net/manual/en/function.exec.php) :
$launchGeneration = function ($appName, $id_application) {
$cmd = "gradlew assembleDebug && cd ../../../api2 && php scriptUpdate.php " . $id_application;
chdir("../api/tmp/" . $appName . "/");
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
exec($cmd);
};
With this method, the navigator won't wait for the commands to finish but the problem is that I also need the first command to be finish before the others can start. The first one will build an application and only then the third one will modify some data in my database to change the status of the compilation from "waiting" to "done". But in this case, the status will be changed to "done" before the end of the build.
At the moment I am working on Windows but in the end, it will be running on a unix system. If it can't be done with Windows I can switch with debian.
Is there any way to launch several commands one by one without blocking the navigator ?