protected function execInBackground($command, $output = null)
{
$output = $output ?: ($this->useWindows() ? 'nul' : '/dev/null');
// no output by default
if ($this->useWindows()) {
// Source: http://arstechnica.com/civis/viewtopic.php?p=9058895&sid=ca678fb8e1cf654f5efae647716a343b#p9058895
if (!class_exists("\\COM")) {
$this->error("Please install COM extension for PHP, see: http://www.php.net/manual/en/com.installation.php");
}
$WshShell = new \COM("WScript.Shell");
$WshShell->Run("cmd /c title {$command} && " . $command . " > " . $output . " 2>&1 &", 2, false);
} else {
// For Linux and Mac OS platforms
// TODO: Try pcntl_exec() function instead
shell_exec(sprintf('%s > ' . $output . ' 2>&1 &', $command));
}
}