Skip to content

Instantly share code, notes, and snippets.

@kadet1090
Created April 19, 2014 14:53
Show Gist options
  • Save kadet1090/11086663 to your computer and use it in GitHub Desktop.
Save kadet1090/11086663 to your computer and use it in GitHub Desktop.
If you've ever dreamed about restarting PHP from PHP script - here you go.
<?php
function restart() {
global $argv;
$cargs = [];
foreach($argv as $arg)
$cargs[] = strpos($arg, ' ') !== false ? '"'.$arg.'"' : $arg;
if(substr(PHP_OS, 0, 3) == 'WIN')
die((new \COM("WScript.Shell"))->Run(PHP_BINARY.' '.implode(' ', $cargs), 0, false));
else
die(exec(PHP_BINARY.' '.implode(' ', $cargs).' > /dev/null &'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment