本文整理汇总了PHP中Symfony\Component\Process\ProcessBuilder::setArguments方法的典型用法代码示例。如果您正苦于以下问题:PHP ProcessBuilder::setArguments方法的具体用法?PHP ProcessBuilder::setArguments怎么用?PHP ProcessBuilder::setArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\ProcessBuilder
的用法示例。
在下文中一共展示了ProcessBuilder::setArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildProcess
/**
* Build a Process to run avahi-browse looking for TiVo on TCP
*
* @return Process
*/
protected function buildProcess()
{
$this->builder->setPrefix('avahi-browse');
$this->builder->setArguments(['--ignore-local', '--resolve', '--terminate', '_tivo-videos._tcp']);
$this->builder->setTimeout(60);
return $this->builder->getProcess();
}
示例2: buildProcess
/**
* Build a Process to run tivodecode decoding a file with a MAK
*
* @param string $mak TiVo's Media Access Key
* @param string $input Where the encoded TiVo file is
* @param string $output Where the decoded MPEG file goes
*
* @return Process
*/
protected function buildProcess($mak, $input, $output)
{
$this->builder->setPrefix('/usr/local/bin/tivodecode');
$this->builder->setArguments([$input, '--mak=' . $mak, '--no-verify', '--out=' . $output]);
$this->builder->setTimeout(null);
return $this->builder->getProcess();
}
示例3: install
/**
* Function to install Laravel
*
* @return string directory where app was installed
*/
public function install()
{
$this->command->comment("Foreman", "Installing fresh Laravel app");
$this->builder->setPrefix('composer');
$this->builder->setArguments(['create-project', 'laravel/laravel', $this->appDir, '--prefer-dist']);
$this->builder->getProcess()->run();
$this->command->comment("Foreman", "Done, Laravel installed at: {$this->appDir}");
return $this->appDir;
}
示例4: executeCommand
/**
* @return string
* @throws \RuntimeException
*/
protected function executeCommand()
{
$this->processBuilder->setArguments(array());
$this->processBuilder->add($this->filePath);
$process = $this->processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
return $process->getOutput();
}
示例5: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$address = $input->getArgument('address') ?: $this->serverAddress;
$output->writeln(sprintf("Server running on <info>%s</info>\n", $address));
$process = $this->processBuilder->setArguments([PHP_BINARY, '-S', $address])->setWorkingDirectory(ROOT . 'web/')->setTimeout(null)->getProcess();
$process->run(function ($type, $buffer) use($output, $input) {
unset($type);
if (!$input->getOption('quiet')) {
$output->write($buffer);
}
});
}
示例6: getProp
/**
* Get a property from youtube-dl.
*
* @param string $url URL to parse
* @param string $format Format
* @param string $prop Property
*
* @return string
*/
private function getProp($url, $format = null, $prop = 'dump-json')
{
$this->procBuilder->setArguments(['--' . $prop, $url]);
if (isset($format)) {
$this->procBuilder->add('-f ' . $format);
}
$process = $this->procBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
throw new \Exception($process->getErrorOutput());
} else {
return $process->getOutput();
}
}
示例7: create
/**
* @return Process
*/
public function create()
{
$processBuilder = new ProcessBuilder();
$processBuilder->setPrefix('vendor/bin/behat');
$processBuilder->setArguments(['--init']);
return $processBuilder->getProcess();
}
示例8: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
echo "Run task: #" . $this->job_id, "\n";
$task = Tasks::find($this->job_id);
$task->status = Tasks::RUN;
$task->save();
$client = new \Hoa\Websocket\Client(new \Hoa\Socket\Client('tcp://127.0.0.1:8889'));
$client->setHost('127.0.0.1');
$client->connect();
$client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $this->job_id, "msg" => json_encode(["jid" => $this->job_id, "status" => Tasks::RUN])]));
$builder = new ProcessBuilder();
$builder->setPrefix('ansible-playbook');
$builder->setArguments(["-i", "inv" . $this->job_id, "yml" . $this->job_id]);
$builder->setWorkingDirectory(storage_path("roles"));
$process = $builder->getProcess();
$process->run();
//echo $process->getOutput() . "\n";
$client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $this->job_id, "msg" => json_encode(["jid" => $this->job_id, "status" => Tasks::FINISH])]));
$client->close();
$task->status = Tasks::FINISH;
$task->content = file_get_contents(storage_path("tmp/log" . $this->job_id . ".txt"));
$task->save();
unlink(storage_path("roles/yml" . $this->job_id));
unlink(storage_path("roles/inv" . $this->job_id));
unlink(storage_path("tmp/log" . $this->job_id . ".txt"));
echo "End task: #" . $this->job_id, "\n";
}
示例9: testShouldSetArguments
public function testShouldSetArguments()
{
$pb = new ProcessBuilder(array('initial'));
$pb->setArguments(array('second'));
$proc = $pb->getProcess();
$this->assertContains("second", $proc->getCommandLine());
}
示例10: execute
/**
* Execute this task
*
* @param \TYPO3\Surf\Domain\Model\Node $node
* @param \TYPO3\Surf\Domain\Model\Application $application
* @param \TYPO3\Surf\Domain\Model\Deployment $deployment
* @param array $options
* @throws \TYPO3\Surf\Exception\InvalidConfigurationException
* @return void
*/
public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
{
$this->assertRequiredOptionsExist($options);
$dumpCommand = new ProcessBuilder();
$dumpCommand->setPrefix('mysqldump');
$dumpCommand->setArguments(array('-h', $options['sourceHost'], '-u', $options['sourceUser'], '-p' . $options['sourcePassword'], $options['sourceDatabase']));
$mysqlCommand = new ProcessBuilder();
$mysqlCommand->setPrefix('mysql');
$mysqlCommand->setArguments(array('-h', $options['targetHost'], '-u', $options['targetUser'], '-p' . $options['targetPassword'], $options['targetDatabase']));
$arguments = array();
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$arguments[] = $username . $hostname;
if ($node->hasOption('port')) {
$arguments[] = '-P';
$arguments[] = $node->getOption('port');
}
$arguments[] = $mysqlCommand->getProcess()->getCommandLine();
$sshCommand = new ProcessBuilder();
$sshCommand->setPrefix('ssh');
$sshCommand->setArguments($arguments);
$command = $dumpCommand->getProcess()->getCommandLine() . ' | ' . $sshCommand->getProcess()->getCommandLine();
$localhost = new Node('localhost');
$localhost->setHostname('localhost');
$this->shell->executeOrSimulate($command, $localhost, $deployment);
}
示例11: FilesCollection
function it_does_not_do_anything_if_there_are_no_keywords(ProcessBuilder $processBuilder, ContextInterface $context)
{
$processBuilder->add(Argument::any())->shouldNotBeCalled();
$processBuilder->setArguments(Argument::any())->shouldNotBeCalled();
$processBuilder->getProcess()->shouldNotBeCalled();
$context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file1.php'))));
$this->run($context)->shouldBeNull();
}
示例12: FilesCollection
function it_does_not_do_anything_if_there_are_no_keywords(ProcessBuilder $processBuilder)
{
$processBuilder->add(Argument::any())->shouldNotBeCalled();
$processBuilder->setArguments(Argument::any())->shouldNotBeCalled();
$processBuilder->getProcess()->shouldNotBeCalled();
$files = new FilesCollection(array(new SplFileInfo('file1.php')));
$this->run($files)->shouldBeNull();
}
示例13: testArrayPrefixesArePrependedToAllGeneratedProcess
public function testArrayPrefixesArePrependedToAllGeneratedProcess()
{
$pb = new ProcessBuilder();
$pb->setPrefix(array('/usr/bin/php', 'composer.phar'));
$proc = $pb->setArguments(array('-v'))->getProcess();
if ('\\' === DIRECTORY_SEPARATOR) {
$this->assertEquals('"/usr/bin/php" "composer.phar" "-v"', $proc->getCommandLine());
} else {
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-v'", $proc->getCommandLine());
}
$proc = $pb->setArguments(array('-i'))->getProcess();
if ('\\' === DIRECTORY_SEPARATOR) {
$this->assertEquals('"/usr/bin/php" "composer.phar" "-i"', $proc->getCommandLine());
} else {
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-i'", $proc->getCommandLine());
}
}
示例14: createProcess
/**
* Create process object
*
* @param string $inputFile
*
* @throws \RuntimeException
*
* @return Process
*/
public function createProcess($inputFile)
{
if (!is_file($inputFile)) {
throw new \RuntimeException('Input file does not exist');
}
$arguments = array_values($this->arguments->toArray());
array_push($arguments, '-f', $inputFile);
return $this->builder->setArguments($arguments)->getProcess();
}
示例15: getProcess
/**
* @return Process
*/
private function getProcess()
{
if (!$this->process) {
$this->processBuilder->setPrefix($this->utilityCommands[$this->utility]);
$this->processBuilder->setArguments(array_merge($this->utilityArguments[$this->utility], [$this->image]));
$this->process = $this->processBuilder->getProcess();
}
return $this->process;
}