Constructor.
@api
string $commandline The command line to run:
string $cwd The working directory:
array $env The environment variables or null to inherit:
string $stdin The STDIN content:
integer $timeout The timeout in seconds:
array $options An array of options for proc_open:
\RuntimeException When proc_open is not installed
public function __construct($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()) {
if (!function_exists('proc_open')) {
throw new \RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
}
$this->commandline = $commandline;
$this->cwd = null === $cwd ? getcwd() : $cwd;
if (null !== $env) {
$this->env = array();
foreach ($env as $key => $value) {
$this->env[(string) $key] = (string) $value;
}
}
else {
$this->env = null;
}
$this->stdin = $stdin;
$this
->setTimeout($timeout);
$this->enhanceWindowsCompatibility = true;
$this->options = array_replace(array(
'suppress_errors' => true,
'binary_pipes' => true,
), $options);
}