public __construct ( string $commandline, string | null $cwd = null, array $env = null, mixed | null $input = null, integer | float | null $timeout = 60, array $options = [] ) | ||
$commandline | string | The command line to run |
$cwd | string | null | The working directory or null to use the working dir of the current PHP process |
$env | array | The environment variables or null to use the same environment as the current PHP process |
$input | mixed | null | The input as stream resource, scalar or \Traversable, or null for no input |
$timeout | integer | float | null | The timeout in seconds or null to disable |
$options | array | An array of options for proc_open |
public function __construct($commandline, $cwd = null, array $env = null, $input = 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 = $cwd;
// on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
// @see : https://bugs.php.net/bug.php?id=51800
// @see : https://bugs.php.net/bug.php?id=50524
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || '\\' === DIRECTORY_SEPARATOR)) {
$this->cwd = getcwd();
}
if (null !== $env) {
$this->setEnv($env);
}
$this->setInput($input);
$this->setTimeout($timeout);
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
$this->pty = false;
$this->enhanceWindowsCompatibility = true;
$this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
}
public function __construct($port, $host) { $this->port = $port; $this->host = $host; parent::__construct(sprintf('exec php -dalways_populate_raw_post_data=-1 -derror_log= -S %s -t public/ public/index.php', $this->getConnectionString()), __DIR__ . '/../../../../'); $this->setTimeout(null); }