当前位置: 首页>>代码示例>>PHP>>正文


PHP Process::getCommandLine方法代码示例

本文整理汇总了PHP中Symfony\Component\Process\Process::getCommandLine方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::getCommandLine方法的具体用法?PHP Process::getCommandLine怎么用?PHP Process::getCommandLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Process\Process的用法示例。


在下文中一共展示了Process::getCommandLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runProcess

 /**
  * @param Process     $process
  * @param bool        $mustRun
  * @param bool        $quiet
  *
  * @return int|string
  * @throws \Exception
  */
 protected function runProcess(Process $process, $mustRun = false, $quiet = true)
 {
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->writeln("Running command: <info>" . $process->getCommandLine() . "</info>");
     }
     try {
         $process->mustRun($quiet ? null : function ($type, $buffer) {
             $this->output->write(preg_replace('/^/m', '  ', $buffer));
         });
     } catch (ProcessFailedException $e) {
         if (!$mustRun) {
             return $process->getExitCode();
         }
         // The default for ProcessFailedException is to print the entire
         // STDOUT and STDERR. But if $quiet is disabled, then the user will
         // have already seen the command's output.  So we need to re-throw
         // the exception with a much shorter message.
         $message = "The command failed with the exit code: " . $process->getExitCode();
         $message .= "\n\nFull command: " . $process->getCommandLine();
         if ($quiet) {
             $message .= "\n\nError output:\n" . $process->getErrorOutput();
         }
         throw new \Exception($message);
     }
     $output = $process->getOutput();
     return $output ? rtrim($output) : true;
 }
开发者ID:ecolinet,项目名称:platformsh-cli,代码行数:35,代码来源:ShellHelper.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $env = array('APP_INCLUDE' => $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/autoload.php', 'VVERBOSE' => 1, 'QUEUE' => $input->getArgument('queues'));
     $workerCommand = 'php ' . $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/chrisboulton/php-resque/resque.php';
     if (!$input->getOption('foreground')) {
         $workerCommand = 'nohup ' . $workerCommand . ' > ' . $this->getContainer()->getParameter('kernel.logs_dir') . '/resque.log 2>&1 & echo $!';
     }
     $process = new Process($workerCommand, null, $env);
     $output->writeln(\sprintf('Starting worker <info>%s</info>', $process->getCommandLine()));
     // if foreground, we redirect output
     if ($input->getOption('foreground')) {
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $process->run();
         $pid = \trim($process->getOutput());
         if (function_exists('gethostname')) {
             $hostname = gethostname();
         } else {
             $hostname = php_uname('n');
         }
         $output->writeln(\sprintf('<info>Worker started</info> %s:%s:%s', $hostname, $pid, $input->getArgument('queues')));
     }
 }
开发者ID:rosstuck,项目名称:BCCResqueBundle,代码行数:25,代码来源:StartWorkerCommand.php

示例3: 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());
 }
开发者ID:phpro,项目名称:grumphp,代码行数:12,代码来源:PhpCsFixerFormatter.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $apply = $input->getOption('apply');
     $filename = 'app/config/parameters.yml';
     if (!file_exists($filename)) {
         throw new RuntimeException("No such file: " . $filename);
     }
     $data = file_get_contents($filename);
     $config = Yaml::parse($data);
     if (isset($config['pdo'])) {
         $pdo = $config['pdo'];
     } else {
         if (!isset($config['parameters']['pdo'])) {
             throw new RuntimeException("Can't find pdo configuration");
         }
         $pdo = $config['parameters']['pdo'];
     }
     $cmd = 'vendor/bin/dbtk-schema-loader schema:load app/schema.xml ' . $pdo;
     if ($apply) {
         $cmd .= ' --apply';
     }
     $process = new Process($cmd);
     $output->writeLn($process->getCommandLine());
     $process->run();
     if (!$process->isSuccessful()) {
         throw new ProcessFailedException($process);
     }
     $output->write($process->getOutput());
 }
开发者ID:radvance,项目名称:radvance,代码行数:32,代码来源:SchemaLoadCommand.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var QuestionHelper $helper */
     $helper = $this->getHelper('question');
     $target = $this->rootPath . '/' . basename($this->pathToPackage);
     $question = new ConfirmationQuestion(sprintf('<question>File in %s already exists. Replace?</question> [yN] ', $target), false);
     if (!file_exists($target) || $helper->ask($input, $output, $question)) {
         copy($this->pathToPackage, $target);
         $output->writeln(sprintf('Dumped default package to <info>%s</info>', $target));
     } else {
         $output->writeln(sprintf('Please update <info>%s</info> by example in <info>%s</info> manually', $target, $this->pathToPackage));
     }
     $target = $this->configPath . '/' . basename($this->pathToWebpackConfig);
     $question = new ConfirmationQuestion(sprintf('<question>File in %s already exists. Replace?</question> [yN] ', $target), false);
     if (!file_exists($target) || $helper->ask($input, $output, $question)) {
         copy($this->pathToWebpackConfig, $target);
         $output->writeln(sprintf('Dumped default webpack config to <info>%s</info>', $target));
     } else {
         $output->writeln(sprintf('Please update <info>%s</info> by example in <info>%s</info> manually', $target, $this->pathToWebpackConfig));
     }
     $process = new Process('npm install', $this->rootPath);
     $question = new ConfirmationQuestion(sprintf('<question>Should I install node dependencies?</question> (%s) [Yn] ', $process->getCommandLine()), true);
     if ($helper->ask($input, $output, $question)) {
         $process->setTimeout(600);
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $output->writeln('Please update dependencies manually before compiling webpack assets');
     }
     $output->writeln('Run <bg=white;fg=black>maba:webpack:compile</> to compile assets when deploying');
     $output->writeln('Always run <bg=white;fg=black>maba:webpack:dev-server</> in dev environment');
 }
开发者ID:mariusbalcytis,项目名称:webpack-bundle,代码行数:33,代码来源:SetupCommand.php

示例6: runCommandProcess

 private function runCommandProcess($cmd, OutputInterface $output)
 {
     $process = new Process($cmd);
     $output->writeLn('<comment>' . $process->getCommandLine() . '</comment>');
     $process->run();
     $output->writeLn($process->getOutput());
 }
开发者ID:radvance,项目名称:radvance,代码行数:7,代码来源:CodeUpdateCommand.php

示例7: testSleeperCommand

 /**
  * @group console
  */
 public function testSleeperCommand()
 {
     // init
     $sleeperCommand = new SleeperCommand();
     $sleeperCommandLockFilePath = sprintf('%s/lock_command_%s', $this->getClient()->getKernel()->getCacheDir(), str_replace(':', '_', $sleeperCommand->getName()));
     $commandline = sprintf('env bin/console --env=%s %s', $this->getClient()->getKernel()->getEnvironment(), $sleeperCommand->getName());
     // the first run of this command with the locking mechanism: the lock is created
     $firstProcess = new Process($commandline);
     $firstProcess->start();
     sleep(SleeperCommand::SLEEPING_TIME / 2);
     // the second run of this command is invalid
     $secondProcess = new Process($commandline);
     $secondProcess->run();
     $this->assertSame(2, $secondProcess->getExitCode(), 'Invalid exit code');
     $secondProcessOutput = $secondProcess->getOutput();
     $this->assertSame(2, substr_count($secondProcessOutput, PHP_EOL), 'There is more than two lines');
     $this->assertContains('locking is activated', $secondProcessOutput, 'Incorrect line 1');
     $this->assertContains('will not be started', $secondProcessOutput, 'Incorrect line 2');
     // check the first process is still running
     $this->assertTrue($firstProcess->isRunning(), sprintf('The command %s does not work', $firstProcess->getCommandLine()));
     // after the sleeping, the lock is released
     sleep(1 + SleeperCommand::SLEEPING_TIME / 2);
     $this->assertSame(0, $firstProcess->getExitCode());
     $firstProcessOutput = $firstProcess->getOutput();
     $this->assertSame(3, substr_count($firstProcessOutput, PHP_EOL), 'There is more than three lines');
     $this->assertContains('starting', $firstProcessOutput);
     $this->assertContains('processing', $firstProcessOutput);
     $this->assertContains('ending', $firstProcessOutput);
     // the third run of this command, after the sleeping, is valid
     $thirdProcess = new Process($commandline);
     $thirdProcess->run();
     $this->assertSame(0, $thirdProcess->getExitCode());
 }
开发者ID:kmelia,项目名称:fresh-symfony,代码行数:36,代码来源:LockingTest.php

示例8: start

 /**
  * Starts a wiremock process.
  *
  * @param string $jarPath
  * @param string $logsPath
  * @param string $arguments
  *
  * @throws \Exception
  */
 public function start($ip, $port, $path, $logsPath, $debug)
 {
     $phiremockPath = is_file($path) ? $path : "{$path}/phiremock";
     $this->process = new Process($this->getCommandPrefix() . "{$phiremockPath} -i {$ip} -p {$port}" . ($debug ? ' -d' : ''));
     if ($debug) {
         echo 'Executing: ' . $this->process->getCommandLine() . PHP_EOL;
     }
     $logFile = $logsPath . DIRECTORY_SEPARATOR . self::LOG_FILE_NAME;
     $this->process->start(function ($type, $buffer) use($logFile) {
         file_put_contents($logFile, $buffer, FILE_APPEND);
     });
     $this->process->setEnhanceSigchildCompatibility(true);
     if ($this->isWindows()) {
         $this->process->setEnhanceWindowsCompatibility(true);
     }
 }
开发者ID:mcustiel,项目名称:phiremock-codeception-extension,代码行数:25,代码来源:PhiremockProcess.php

示例9: __construct

 public function __construct(Process $process)
 {
     $error = sprintf('PHP error message was detected when running this command:' . PHP_EOL . '  %s' . PHP_EOL . 'Moodle scripts should run without any PHP errors.', $process->getCommandLine());
     if (!$process->isOutputDisabled()) {
         $error .= sprintf("\n\nError Output\n============\n%s", $process->getErrorOutput());
     }
     parent::__construct($error);
 }
开发者ID:gjb2048,项目名称:moodle-plugin-ci,代码行数:8,代码来源:MoodlePhpException.php

示例10: __construct

 public function __construct(Process $process)
 {
     if ($process->isSuccessful()) {
         throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.');
     }
     parent::__construct(sprintf('The command "%s" failed.' . "\n\nOutput:\n================\n" . $process->getOutput() . "\n\nError Output:\n================\n" . $process->getErrorOutput(), $process->getCommandLine()));
     $this->process = $process;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:8,代码来源:ProcessFailedException.php

示例11: runCommands

 public function runCommands()
 {
     $commands = implode('; ', $this->getCommands());
     $process = new Process($commands, $this->getPath());
     $process->setTimeout(600);
     $process->setIdleTimeout(null);
     $this->logger->info('Running "' . $process->getCommandLine() . '"');
     $process->mustRun();
 }
开发者ID:anorgan,项目名称:deployer-common,代码行数:9,代码来源:Local.php

示例12: runProcess

 /**
  * @param OutputInterface $output
  * @param Process $process
  */
 private function runProcess(OutputInterface $output, Process $process)
 {
     if ($output->getVerbosity() >= $output::VERBOSITY_VERBOSE) {
         $output->writeln(sprintf('<comment>Execute: <info>%s</info></comment>', $process->getCommandLine()));
     }
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
开发者ID:cmuench,项目名称:phpstorm-downloader,代码行数:14,代码来源:DownloadCommand.php

示例13: forProcess

 public static function forProcess(Process $process)
 {
     $shortError = $fullError = $process->getErrorOutput();
     if (preg_match('~^fatal: (.+)$~', $shortError, $matches)) {
         $shortError = trim($matches[1]);
     } elseif (preg_match('~^\\s+\\[([\\w\\\\]+\\\\)?(\\w+)\\]\\s+(.+)\\n\\n\\S~s', $shortError, $matches)) {
         $shortError = trim($matches[2]) . ': ' . trim($matches[3]);
     }
     return new static($process->getCommandLine(), $process->getExitCode(), $shortError, $fullError);
 }
开发者ID:niklongstone,项目名称:composer-plugin,代码行数:10,代码来源:PuliRunnerException.php

示例14: run

 /**
  * @param Process $process
  */
 public function run(Process $process)
 {
     $this->logger->debug(sprintf('Webhook process started: "%s".', $command = $process->getCommandLine()));
     $process->run();
     if ($process->isSuccessful()) {
         $this->logger->debug(sprintf('Webhook process finished: "%s".', $command), ['output' => $process->getOutput()]);
     } else {
         $this->logger->error(sprintf('Webhook process errored: "%s".', $command), ['output' => $process->getOutput(), 'error' => $process->getErrorOutput()]);
     }
 }
开发者ID:php-lug,项目名称:webhook,代码行数:13,代码来源:ProcessRunner.php

示例15: run

 /**
  * {@inheritdoc}
  */
 public function run(Process $process, $mustSucceed = true)
 {
     $this->userInteraction->write('<info>RUN</info> ' . $process->getCommandLine());
     if ($mustSucceed) {
         $process->setTimeout(null);
         return $process->mustRun($this->getRunningProcessCallback());
     }
     $process->run($this->getRunningProcessCallback());
     return $process;
 }
开发者ID:richardmiller,项目名称:dock-cli,代码行数:13,代码来源:InteractiveProcessRunner.php


注:本文中的Symfony\Component\Process\Process::getCommandLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。