Beispiel #1
0
 static function fork($phpScript, $phpExec = null)
 {
     $cwd = dirname($phpScript);
     @putenv("PHP_FORCECLI=true");
     if (!is_string($phpExec) || !file_exists($phpExec)) {
         if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
             $phpExec = str_replace('/', '\\', dirname(ini_get('extension_dir'))) . '\\php.exe';
             if (@file_exists($phpExec)) {
                 BackgroundProcess::open(escapeshellarg($phpExec) . " " . escapeshellarg($phpScript), $cwd);
             }
         } else {
             $phpExec = exec("which php-cli");
             if ($phpExec[0] != '/') {
                 $phpExec = exec("which php");
             }
             if ($phpExec[0] == '/') {
                 BackgroundProcess::open(escapeshellarg($phpExec) . " " . escapeshellarg($phpScript), $cwd);
             }
         }
     } else {
         if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
             $phpExec = str_replace('/', '\\', $phpExec);
         }
         BackgroundProcess::open(escapeshellarg($phpExec) . " " . escapeshellarg($phpScript), $cwd);
     }
 }