本文整理汇总了PHP中Symfony\Component\Process\ProcessUtils类的典型用法代码示例。如果您正苦于以下问题:PHP ProcessUtils类的具体用法?PHP ProcessUtils怎么用?PHP ProcessUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProcessUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProjectNew
public function testProjectNew()
{
$projectDir = sprintf('%s/my_test_project', sys_get_temp_dir());
$this->fs->remove($projectDir);
$output = $this->runCommand(sprintf('php crush.phar project new %s', ProcessUtils::escapeArgument($projectDir)));
$this->assertContains('Projects process exited.', $output);
}
示例2: formatSuggestion
/**
* @param Process $process
*
* @return string
*/
public function formatSuggestion(Process $process)
{
$pattern = '%s ';
$dryrun = sprintf($pattern, ProcessUtils::escapeArgument('--dry-run'));
$formatJson = sprintf($pattern, ProcessUtils::escapeArgument('--format=json'));
return str_replace([$dryrun, $formatJson], '', $process->getCommandLine());
}
示例3: createProcessForFile
/**
* Create process that lint PHP file.
*
* @param string $path path to file
*
* @return Process
*/
public function createProcessForFile($path)
{
$process = new Process('php -l ' . ProcessUtils::escapeArgument($path));
$process->setTimeout(null);
$process->run();
return $process;
}
示例4: escape
/**
* Escape the provided value, unless it contains only alphanumeric
* plus a few other basic characters.
*
* @param string $value
* @return string
*/
public static function escape($value)
{
if (preg_match('/^[a-zA-Z0-9\\/.@~_-]*$/', $value)) {
return $value;
}
return ProcessUtils::escapeArgument($value);
}
示例5: lintFile
/**
* @param $path
* @return Process
*/
protected function lintFile($path)
{
$lintProcess = new Process('php -l ' . ProcessUtils::escapeArgument($path));
$lintProcess->setTimeout(null);
$lintProcess->run();
return strpos($lintProcess->getOutput(), 'No syntax errors detected in') === 0;
}
示例6: scan
/**
* @param array $targets
* @param array $ports
*
* @return Host[]
*/
public function scan(array $targets, array $ports = array())
{
$targets = implode(' ', array_map(function ($target) {
return ProcessUtils::escapeArgument($target);
}, $targets));
$options = array();
if (true === $this->enableOsDetection) {
$options[] = '-O';
}
if (true === $this->enableServiceInfo) {
$options[] = '-sV';
}
if (true === $this->enableVerbose) {
$options[] = '-v';
}
if (true === $this->disablePortScan) {
$options[] = '-sn';
} elseif (!empty($ports)) {
$options[] = '-p ' . implode(',', $ports);
}
if (true === $this->disableReverseDNS) {
$options[] = '-n';
}
if (true == $this->treatHostsAsOnline) {
$options[] = '-Pn';
}
$options[] = '-oX';
$command = sprintf('%s %s %s %s', $this->executable, implode(' ', $options), ProcessUtils::escapeArgument($this->outputFile), $targets);
$this->executor->execute($command);
if (!file_exists($this->outputFile)) {
throw new \RuntimeException(sprintf('Output file not found ("%s")', $this->outputFile));
}
return $this->parseOutputFile($this->outputFile);
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$host = $input->getOption('host');
$port = $input->getOption('port');
$daux = $this->prepareDaux($input);
// Daux can only serve HTML
$daux->getParams()->setFormat('html');
chdir(__DIR__ . '/../../');
putenv('DAUX_SOURCE=' . $daux->getParams()->getDocumentationDirectory());
putenv('DAUX_THEME=' . $daux->getParams()->getThemesPath());
putenv('DAUX_CONFIGURATION=' . $daux->getParams()->getConfigurationOverrideFile());
putenv('DAUX_EXTENSION=' . DAUX_EXTENSION);
$base = ProcessUtils::escapeArgument(__DIR__ . '/../../');
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
echo "Daux development server started on http://{$host}:{$port}/\n";
if (defined('HHVM_VERSION')) {
if (version_compare(HHVM_VERSION, '3.8.0') >= 0) {
passthru("{$binary} -m server -v Server.Type=proxygen -v Server.SourceRoot={$base}/ -v Server.IP={$host} -v Server.Port={$port} -v Server.DefaultDocument=server.php -v Server.ErrorDocument404=server.php");
} else {
throw new Exception("HHVM's built-in server requires HHVM >= 3.8.0.");
}
} else {
passthru("{$binary} -S {$host}:{$port} {$base}/index.php");
}
}
示例8: prepare
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());
}
示例9: findComposer
/**
* Get the composer command for the environment.
*
* @return string
*/
protected function findComposer()
{
if (!$this->files->exists($this->workingPath . '/composer.phar')) {
return 'composer';
}
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
return "{$binary} composer.phar";
}
示例10: checkoutReference
private function checkoutReference(Source $source, $path)
{
$process = new Process(sprintf('git checkout -f %s -- && git reset --hard %1$s --', ProcessUtils::escapeArgument($source->getReference())), realpath($path));
$process->run();
if (preg_match('/fatal: reference is not a tree: (.+)/', $process->getErrorOutput(), $matches)) {
throw new RuntimeException('Failed to checkout ' . $source->getReference());
}
}
示例11: ProcessArgumentsCollection
function it_outputs_the_command_when_run_very_very_verbose(GrumPHP $config, ExternalCommand $externalCommandLocator, IOInterface $io)
{
$io->isVeryVerbose()->willReturn(true);
$command = '/usr/bin/grumphp';
$io->write(PHP_EOL . 'Command: ' . ProcessUtils::escapeArgument($command), true)->shouldBeCalled();
$arguments = new ProcessArgumentsCollection([$command]);
$process = $this->buildProcess($arguments);
}
示例12: extractShell
private function extractShell()
{
$command = 'tar -jxvf ' . ProcessUtils::escapeArgument($this->file) . ' -C ' . ProcessUtils::escapeArgument($this->path) . ' && chmod -R u+w ' . ProcessUtils::escapeArgument($this->path);
$process = new Process($command);
$process->run();
echo $process->getErrorOutput();
return $process->isSuccessful();
}
示例13: execute
/**
* Executes command to start a development server.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$host = $input->getOption('host');
$port = $input->getOption('port');
$base = ProcessUtils::escapeArgument(realpath(__DIR__ . '/../../../../public'));
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
$output->writeln("<info>PHP development server started on http://{$host}:{$port}</info>");
passthru("{$binary} -S {$host}:{$port} -t {$base}");
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$host = $input->getOption('host');
$port = $input->getOption('port');
$this->info('Blog-Tree development server started on http://' . $host . ':' . $port . '/');
$base = ProcessUtils::escapeArgument($this->app->basePath());
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
passthru("{$binary} -S {$host}:{$port} {$base}/server.php");
}
示例15: execute
/**
* Ejecuta el comando
*
* @param InputInterface $input Instancia
* @param OutputInterface $output Instancia
*
* @return [type] [description]
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$host = $input->getOption('host');
$port = $input->getOption('port');
$target = $input->getOption('target');
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
$output->writeln("Resty development server started on http://{$host}:{$port}/ -t {$target}");
$cmd = "{$binary} -S {$host}:{$port} -t {$target}";
passthru($cmd);
}