php Symfony-Component-Process-ProcessUtils类(方法)实例源码

下面列出了php Symfony-Component-Process-ProcessUtils 类(方法)源码代码实例,从而了解它的用法。

作者:cocomor    项目:crus   
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);
 }

作者:phpr    项目:grumph   
/**
  * @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());
 }

作者:brighten0    项目:opencloud-zendframewor   
/**
  * 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;
 }

作者:greg-1-anderso    项目:Rob   
/**
  * 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);
 }

作者:hacf    项目:php-file-analyze   
/**
  * @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;
 }

作者:willduran    项目:nma   
/**
  * @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);
 }

作者:justinwals    项目:daux.i   
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");
     }
 }

作者:alnutil    项目:drunatr   
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());
 }

作者:davidhemphil    项目:framewor   
/**
  * 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";
 }

作者:pixelpolisher    项目:resolve   
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());
     }
 }

作者:phpr    项目:grumph   
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);
 }

作者:JBarnde    项目:update   
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();
 }

作者:mobiste    项目:wordpres   
/**
  * 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}");
 }

作者:blog-tre    项目:lib-bt-kerne   
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");
 }

作者:restyph    项目:rest   
/**
  * 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);
 }

作者:scase    项目:CloudBackupBundl   
/**
  * {@inheritdoc}
  */
 public function getCompressionCommand($archivePath, $basePath)
 {
     $tarParams = array();
     $zipParams = array();
     if (isset($this->options['compression_ratio']) && $this->options['compression_ratio'] >= 0) {
         $compression_ratio = max(min($this->options['compression_ratio'], 9), 0);
         $zipParams[] = '-' . $compression_ratio;
     }
     return sprintf('tar %s c -C %s . | gzip %s > %s', implode(' ', $tarParams), ProcessUtils::escapeArgument($basePath), implode(' ', $zipParams), ProcessUtils::escapeArgument($archivePath));
 }

作者:Ryu062    项目:SaNaV   
public function createProcessForFile($path)
 {
     if (!is_file($path)) {
         return $this->createProcessForSource(file_get_contents($path));
     }
     $process = new Process('php -l ' . ProcessUtils::escapeArgument($path));
     $process->setTimeout(null);
     $process->run();
     return $process;
 }

作者:Ener-Getic    项目:symfon   
/**
  * Appends an input to the write buffer.
  *
  * @param resource|scalar|\Traversable|null The input to append as stream resource, scalar or \Traversable
  */
 public function write($input)
 {
     if (null === $input) {
         return;
     }
     if ($this->isClosed()) {
         throw new RuntimeException(sprintf('%s is closed', static::class));
     }
     $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
 }

作者:davidhemphil    项目:framewor   
/**
  * Execute the console command.
  *
  * @return void
  *
  * @throws \Exception
  */
 public function fire()
 {
     chdir($this->laravel->publicPath());
     $host = $this->input->getOption('host');
     $port = $this->input->getOption('port');
     $base = ProcessUtils::escapeArgument($this->laravel->basePath());
     $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
     $this->info("Laravel development server started on http://{$host}:{$port}/");
     passthru("{$binary} -S {$host}:{$port} {$base}/server.php");
 }

作者:narog    项目:symfony-installe   
/**
  * @dataProvider provideSymfonyInstallationData
  */
 public function testSymfonyInstallation($commandArguments, $messageRegexp, $versionRegexp)
 {
     $projectDir = sprintf('%s/my_test_project', sys_get_temp_dir());
     $this->fs->remove($projectDir);
     $output = $this->runCommand(sprintf('php symfony.phar new %s %s', ProcessUtils::escapeArgument($projectDir), $commandArguments));
     $this->assertContains('Downloading Symfony...', $output);
     $this->assertRegExp($messageRegexp, $output);
     $output = $this->runCommand('php app/console --version', $projectDir);
     $this->assertRegExp($versionRegexp, $output);
 }


问题


面经


文章

微信
公众号

扫码关注公众号