__construct() public method

Constructor.
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
示例#1
0
 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);
 }
 public function __construct($script, $duration)
 {
     $this->script = $script;
     $this->initialDuration = $duration;
     $this->enableOutput();
     parent::__construct($script, null, null, null, null, []);
 }
 /**
  * @param string         $script  Passed to php binary
  * @param string|null    $cwd     The working directory or null to use the working dir of the current PHP process
  * @param array|null     $env     The environment variables or null to inherit
  * @param int|float|null $timeout The timeout in seconds or null to disable
  */
 public function __construct($script, $cwd = null, array $env = null, $timeout = null)
 {
     // By telling PHP to log errors without having a log file, PHP will write
     // errors to STDERR in a specific format (each line is prefixed with PHP).
     $commandline = sprintf('php -d log_errors=1 -d error_log=NULL %s', $script);
     parent::__construct($commandline, $cwd, $env, null, $timeout);
 }
 /**
  * ScenarioProcess constructor.
  *
  * @param ScenarioInfo $scenarioInfo
  * @param null|string  $commandline
  * @param null         $cwd
  * @param array|null   $env
  * @param null         $input
  * @param int          $timeout
  * @param array        $options
  */
 public function __construct(ScenarioInfo $scenarioInfo, $commandline, $cwd = null, array $env = null, $input = null, $timeout = 0, array $options = array())
 {
     $this->scenarioInfo = $scenarioInfo;
     $this->commandLine = $commandline;
     $this->optionCollection = new ProcessOptionCollection();
     parent::__construct($this->getCommandLineWithOptions(), $cwd, $env, $input, $timeout, $options);
 }
示例#5
0
 public function prepare(BehatWrapper $behat, BehatCommand $command, $cwd = null)
 {
     // Build the command line options, flags, and arguments.
     $binary = ProcessUtils::escapeArgument($behat->getBehatBinary());
     $commandLine = rtrim($binary . ' ' . $command->getCommandLine());
     parent::__construct($commandLine, $cwd, null, null, $behat->getTimeout(), array());
 }
 public function __construct(Container $container, Container $parent = null)
 {
     $cmd = 'lxc-info -s -n ' . $container->getName();
     if (!empty($parent)) {
         $cmd = 'lxc-attach -n ' . $parent->getName() . ' -- ' . $cmd;
     }
     parent::__construct($cmd);
 }
示例#7
0
 /**
  * Constructor.
  *
  * @param string $script The PHP script to run (as a string)
  * @param string|null $cwd The working directory or null to use the working dir of the current PHP process
  * @param array|null $env The environment variables or null to use the same environment as the current PHP process
  * @param int $timeout The timeout in seconds
  * @param array $options An array of options for proc_open
  */
 public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
 {
     $executableFinder = new PhpExecutableFinder();
     if (false === ($php = $executableFinder->find())) {
         $php = null;
     }
     parent::__construct($php, $cwd, $env, $script, $timeout, $options);
 }
示例#8
0
 public function __construct($command, $input = NULL)
 {
     parent::__construct($command);
     $this->setInput($input);
     $this->setTimeout(0);
     $this->identifier = md5(uniqid());
     $this->log = new \Nethgui\Log\Nullog();
 }
 public function __construct($profileName, $profileVersion, $downloadHost = null)
 {
     $cmd = 'rprofmgr profile:download-version --profile-version=' . escapeshellarg($profileVersion);
     if (!empty($downloadHost)) {
         $cmd .= ' --download-host=' . escapeshellarg($downloadHost);
     }
     $cmd .= ' ' . escapeshellarg($profileName);
     parent::__construct($cmd);
 }
示例#10
0
 /**
  * Use the Builder to create a environment process
  */
 public function __construct($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
 {
     $env = array_replace(array('USERPROFILE' => getenv('HOME')), (array) $env);
     $inherits = array('PATH', 'SystemRoot', 'LOCALAPPDATA', 'SystemDrive', 'SSH_AUTH_SOCK', 'CommonProgramFiles', 'APPDATA', 'COMPUTERNAME', 'TEMP', 'TMP', 'USERNAME', 'PHPRC', 'PHP_PEAR_BIN_DIR', 'PHP_PEAR_PHP_BIN', 'PSC_CMS', 'XDEBUG_CONFIG', 'WEBFORGE');
     foreach ($inherits as $inherit) {
         $env[$inherit] = getenv($inherit);
     }
     parent::__construct($commandline, $cwd, $env, $stdin, $timeout, $options);
 }
示例#11
0
 /**
  * @param GitWrapper $gitWrapper
  * @param GitCommand $gitCommand
  */
 public function __construct(GitWrapper $gitWrapper, GitCommand $gitCommand)
 {
     $commandLine = ProcessUtils::escapeArgument($gitWrapper->getGitBinary()) . ' ' . $gitCommand->getCommandLine();
     $directory = realpath($gitCommand->getDirectory());
     $envVars = null;
     $wrapperEnvVars = $gitWrapper->getEnvVars();
     if (!empty($wrapperEnvVars)) {
         $envVars = array_merge($_ENV, $_SERVER, $wrapperEnvVars);
     }
     parent::__construct($commandLine, $directory, $envVars, null, $gitCommand->getTimeout());
 }
示例#12
0
文件: Process.php 项目: liuggio/spawn
 /**
  * @param CommandLine        $commandLine
  * @param ProcessEnvironment $processEnvironment
  * @param int|float|null     $timeout
  * @param string|null        $cwd
  */
 public function __construct(CommandLine $commandLine, ProcessEnvironment $processEnvironment, $timeout = null, $cwd = null)
 {
     $this->processEnvironment = $processEnvironment;
     parent::__construct((string) $commandLine, $cwd, $this->processEnvironment->exportToEnvsArray());
     if ($timeout) {
         $this->setTimeout($timeout);
         // compatibility to SF 2.2
         if (method_exists($this, 'setIdleTimeout')) {
             $this->setIdleTimeout($timeout);
         }
     }
 }
示例#13
0
 /**
  * Constructor.
  *
  * @param Console     $console The console
  * @param string      $command The command line to run
  * @param string|null $cwd     The working directory or null to use the
  *                             working dir of the current PHP process
  */
 public function __construct(Console $console, $command, $cwd = null)
 {
     $this->console = $console;
     if (is_string($command)) {
         $command = trim($command);
     } elseif (is_array($command)) {
         $command = implode('; ', $command);
     } else {
         throw new \Netresearch\Kite\Exception('Command must be string or array, ' . gettype($command) . ' given.', 1312454906);
     }
     parent::__construct($command, $cwd, null, null, null);
 }
示例#14
0
 public function __construct($cmd, $cwd = null, $identityfile = null, $passphrase = null, $timeout = 180)
 {
     if (!empty($passphrase)) {
         $command = base_path() . '/scripts/git.sh -i ' . $identityfile . ' ' . $cmd;
         $commandline = $this->expectWithPassphrase($command, $passphrase, $timeout);
     } elseif (!empty($identityfile)) {
         $command = base_path() . '/scripts/git.sh -i ' . $identityfile . ' ' . $cmd;
         $commandline = $this->expect($command, $timeout);
     } else {
         $command = $cmd;
         $commandline = $this->expect($cmd, $timeout);
     }
     parent::__construct($commandline, $cwd);
 }
示例#15
0
 /**
  * Constructor.
  *
  * @param string      $script  The PHP script to run (as a string)
  * @param string|null $cwd     The working directory or null to use the working dir of the current PHP process
  * @param array|null  $env     The environment variables or null to use the same environment as the current PHP process
  * @param int         $timeout The timeout in seconds
  * @param array       $options An array of options for proc_open
  */
 public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
 {
     $executableFinder = new PhpExecutableFinder();
     if (false === ($php = $executableFinder->find())) {
         $php = null;
     }
     if ('phpdbg' === PHP_SAPI) {
         $file = tempnam(sys_get_temp_dir(), 'dbg');
         file_put_contents($file, $script);
         register_shutdown_function('unlink', $file);
         $php .= ' ' . ProcessUtils::escapeArgument($file);
         $script = null;
     }
     parent::__construct($php, $cwd, $env, $script, $timeout, $options);
 }
示例#16
0
 public function __construct($hostname, $address, $username, $remoteCommand, $identityfile = null, $passphrase = null, $cwd = null, $port = 22, $timeout = 180)
 {
     $remoteCommand = addcslashes($remoteCommand, '"');
     if (!empty($passphrase)) {
         $cmd = "ssh -o ConnectTimeout=30 -i {$identityfile} {$username}@{$address} -p {$port} \"{$remoteCommand}\"";
         $commandline = $this->expectWithPassphrase($cmd, $passphrase, $timeout);
     } elseif (!empty($identityfile)) {
         $cmd = "ssh -o ConnectTimeout=30 -i {$identityfile} {$username}@{$address} -p {$port} \"{$remoteCommand}\"";
         $commandline = $this->expect($cmd, $timeout);
     } else {
         $cmd = "ssh -o ConnectTimeout=30 {$hostname} -p {$port} \"{$remoteCommand}\"";
         $commandline = $this->expect($cmd, $timeout);
     }
     parent::__construct($commandline, $cwd);
 }
示例#17
0
 public function __construct($hostname, $address, $username, $exclude, $localDir, $remoteDir, $forceDelete, $identityfile = null, $passphrase = null, $cwd = null, $port = 22, $timeout = 180)
 {
     $identityfile = addcslashes($identityfile, '"');
     $remoteDir = addcslashes($remoteDir, ' ');
     $localDir = addcslashes($localDir, ' ');
     $exclude = addcslashes($exclude, ' ');
     $exclude = empty($exclude) ? '' : " --exclude-from={$exclude} ";
     if (!empty($passphrase)) {
         $cmd = "rsync -az {$forceDelete} --delay-updates -e \\\"ssh -o ConnectTimeout=30 -i \\\\\\\"{$identityfile}\\\\\\\" -p {$port}\\\"" . " {$exclude} {$localDir} {$username}@{$address}:{$remoteDir} ";
         $commandline = $this->expectWithPassphrase($cmd, $passphrase, $timeout);
     } elseif (!empty($identityfile)) {
         $cmd = "rsync -az {$forceDelete} --delay-updates -e \\\"ssh -o ConnectTimeout=30 -i \\\\\\\"{$identityfile}\\\\\\\" -p {$port}\\\"" . " {$exclude} {$localDir} {$username}@{$address}:{$remoteDir} ";
         $commandline = $this->expect($cmd, $timeout);
     } else {
         $cmd = "rsync -az {$forceDelete} --delay-updates -e \\\"ssh -o ConnectTimeout=30 -p {$port}\\\" " . " {$exclude} {$localDir} {$hostname}:{$remoteDir} ";
         $commandline = $this->expect($cmd, $timeout);
     }
     echo $commandline . "\n";
     parent::__construct($commandline, $cwd);
 }
示例#18
0
 /**
  * Constructor.
  *
  * @param string $script
  *        	The PHP script to run (as a string)
  * @param string|null $cwd
  *        	The working directory or null to use the working dir of the current PHP process
  * @param array|null $env
  *        	The environment variables or null to use the same environment as the current PHP process
  * @param int $timeout
  *        	The timeout in seconds
  * @param array $options
  *        	An array of options for proc_open
  */
 public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
 {
     $executableFinder = new PhpExecutableFinder();
     if (false === ($php = $executableFinder->find())) {
         $php = null;
     }
     if ('phpdbg' === PHP_SAPI) {
         $file = tempnam(sys_get_temp_dir(), 'dbg');
         file_put_contents($file, $script);
         register_shutdown_function('unlink', $file);
         $php .= ' ' . ProcessUtils::escapeArgument($file);
         $script = null;
     }
     if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
         // exec is mandatory to deal with sending a signal to the process
         // see https://github.com/symfony/symfony/issues/5030 about prepending
         // command with exec
         $php = 'exec ' . $php;
     }
     parent::__construct($php, $cwd, $env, $script, $timeout, $options);
 }
示例#19
0
 /**
  * Constructs a GitProcess object.
  *
  * @param \GitWrapper\GitWrapper $git
  * @param \GitWrapper\GitCommand $command
  * @param string|null $cwd
  */
 public function __construct(GitWrapper $git, GitCommand $command, $cwd = null)
 {
     $this->git = $git;
     $this->command = $command;
     // Build the command line options, flags, and arguments.
     $binary = ProcessUtils::escapeArgument($git->getGitBinary());
     $commandLine = rtrim($binary . ' ' . $command->getCommandLine());
     // Resolve the working directory of the Git process. Use the directory
     // in the command object if it exists.
     if (null === $cwd) {
         if (null !== ($directory = $command->getDirectory())) {
             if (!($cwd = realpath($directory))) {
                 throw new GitException('Path to working directory could not be resolved: ' . $directory);
             }
         }
     }
     // Finalize the environment variables, an empty array is converted
     // to null which enherits the environment of the PHP process.
     $env = $git->getEnvVars();
     if (!$env) {
         $env = null;
     }
     parent::__construct($commandLine, $cwd, $env, null, $git->getTimeout(), $git->getProcOptions());
 }
 /**
  * __construct 
  * 
  * @param Command $command 
  * @param InputInterface $input 
  * @param mixed $cwd 
  * @param array $env 
  * @param int $timeout 
  * @param array $options 
  * @access public
  * @return void
  */
 public function __construct(Command $command, InputInterface $input, $cwd = null, array $env = array(), $timeout = 60, array $options = array())
 {
     parent::__construct(new CommandFormatter($command, $input), $cwd, $env, $timeout, $options);
 }
示例#21
0
 public function __construct()
 {
     parent::__construct($this->command());
 }
 public function __construct(Container $project)
 {
     $cmd = 'lxc-destroy --name ' . escapeshellarg($project->getName());
     parent::__construct($cmd);
 }
示例#23
0
 public function __construct()
 {
     parent::__construct('');
 }
示例#24
0
 /**
  * Constructor.
  *
  * @param string  $script  The PHP script to run (as a string)
  * @param string  $cwd     The working directory
  * @param array   $env     The environment variables
  * @param integer $timeout The timeout in seconds
  * @param array   $options An array of options for proc_open
  *
  * @api
  */
 public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array())
 {
     parent::__construct(null, $cwd, $env, $script, $timeout, $options);
     $this->executableFinder = new PhpExecutableFinder();
 }
示例#25
0
 /**
  * {@inheritdoc}
  */
 public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = [])
 {
     parent::__construct($commandline, $cwd, $env, $input, $timeout, $options);
     static::$instances[] = $this;
 }
 public function __construct(Container $container)
 {
     $cmd = 'lxc-create --name ' . escapeshellarg($container->getName()) . ' --bdev btrfs --template rainmaker-project' . ' -- --profile ' . escapeshellarg($container->getProfileName()) . ' --version ' . escapeshellarg($container->getProfileVersion());
     parent::__construct($cmd);
 }
 public function __construct($profileName, $profileVersion)
 {
     parent::__construct('rprofmgr profile:version-metadata --profile-version=' . escapeshellarg($profileVersion) . '  ' . escapeshellarg($profileName));
 }
 public function __construct($target)
 {
     parent::__construct('mount ' . $target);
 }
 public function __construct()
 {
     parent::__construct('lxc-attach -n services -- service bind9 reload');
 }
示例#30
0
 public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 3600, array $options = array())
 {
     parent::__construct($commandline, $cwd, $env, $input, $timeout, $options);
 }