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


PHP Process::mustRun方法代码示例

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


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

示例1: run

 /**
  * Runs a process and returns the output.
  *
  * @param Process $process
  * @return string
  */
 public function run(Process $process, $returnOutput = true)
 {
     $process->mustRun();
     if ($returnOutput) {
         return $this->getProcessOutput($process);
     }
 }
开发者ID:wackamole0,项目名称:rainmaker-tool,代码行数:13,代码来源:ProcessRunner.php

示例2: runProcess

 /**
  * @param Process     $process
  * @param bool        $mustRun
  * @param bool        $quiet
  *
  * @return int|string
  * @throws \Exception
  */
 protected function runProcess(Process $process, $mustRun = false, $quiet = true)
 {
     $this->output->writeln("Running command: <info>" . $process->getCommandLine() . "</info>", OutputInterface::VERBOSITY_VERBOSE);
     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:commerceguys,项目名称:platform-cli,代码行数:33,代码来源:ShellHelper.php

示例3: runCommand

 /**
  * Runs the given string as a command and returns the resulting output.
  * The CWD is set to the root project directory to simplify command paths.
  *
  * @param string $command
  *
  * @return string
  *
  * @throws ProcessFailedException in case the command execution is not successful
  */
 private function runCommand($command, $workingDirectory = null)
 {
     $process = new Process($command);
     $process->setWorkingDirectory($workingDirectory ?: $this->rootDir);
     $process->mustRun();
     return $process->getOutput();
 }
开发者ID:slavomirkuzma,项目名称:symfony-installer,代码行数:17,代码来源:IntegrationTest.php

示例4: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->config->load($this->argument('conversion'));
     $command = $this->commandStringBuilder->build($this->config);
     $outputPath = $this->config->outputPath();
     if (file_exists($outputPath)) {
         @unlink($outputPath);
     }
     if ($this->config->debug()) {
         $this->output->block('[DEBUG] Running command: ' . $command);
     }
     if (empty(shell_exec("which mysqldump"))) {
         throw new MissingDependency('mysqldump is not available');
     }
     if (is_executable($this->config->converterExecutable()) === false) {
         $process = new Process('chmod +x ' . $this->config->converterExecutable());
         $process->run();
     }
     $process = new Process($command);
     $outputFilter = $this->outputFilter;
     $process->mustRun(function ($type, $output) use($outputFilter) {
         // some things are expected, so we'll hide that
         // to avoid misleading warnings/errors
         $output = $outputFilter->filter($output);
         if ($output != null) {
             if (Process::ERR === $type) {
                 echo 'ERR > ' . $output;
             } else {
                 echo 'OUT > ' . $output;
             }
         }
     });
     $this->output->success('Dump created at ' . $outputPath);
 }
开发者ID:RealpageLouisville,项目名称:mysql-to-sqlite,代码行数:39,代码来源:ConvertToSqlite.php

示例5: __callStatic

 /**
  * @param string $name
  * @param array  $arguments
  *
  * @throws GulpBadTaskConfigurationException
  * @throws GulpUndefinedTaskException
  */
 public static function __callStatic($name, $arguments)
 {
     $taskName = Inflector::camelCaseToDaseCase($name);
     /** @var Event $event */
     list($event) = $arguments;
     $gulpTasks = self::getOption('gulp-tasks', $event);
     if (!isset($gulpTasks[$taskName])) {
         throw new GulpUndefinedTaskException(sprintf('Gulp %s task is not defined.', $taskName));
     }
     // get gulp options
     $gulpBin = self::getOption('gulp-bin', $event);
     $logPrepend = self::getOption('gulp-log-prepend', $event);
     // get task options
     $taskOptions = $gulpTasks[$taskName];
     if (empty($taskOptions['command'])) {
         throw new GulpBadTaskConfigurationException(sprintf('Gulp %s task command option must be defined.', $taskName));
     }
     $command = [$gulpBin, $taskOptions['command'], isset($taskOptions['params']) ? $taskOptions['params'] : ''];
     $failOnError = empty($taskOptions['fail-on-error']) ? false : $taskOptions['fail-on-error'];
     if (!$failOnError) {
         $command[] = '|| true';
     }
     // execute process
     $process = new Process(implode(' ', $command), null, null, null, null, []);
     $process->mustRun(function ($type, $buffer) use($event, $logPrepend) {
         self::writeProcessBuffer($type, $buffer, $event, $logPrepend);
     });
 }
开发者ID:javihgil,项目名称:composer-ci-tools,代码行数:35,代码来源:Gulp.php

示例6: mustRun

    public function mustRun(array $commands, $timeout = 60)
    {
        $command_format = <<<SHELL
echo {{ESCAPED_COMMAND}}
{{COMMAND}}
SHELL;
        $formatted_commands = $this->formatCommands($commands, $command_format);
        $shell = <<<SHELL
set -e
set -u

{$formatted_commands}
SHELL;
        $log_service = $this->log_service;
        $process = new Process($shell);
        $process->setTimeout($timeout);
        $process->setIdleTimeout($timeout);
        $process->mustRun(function ($type, $buffer) use($log_service) {
            if (Process::ERR === $type) {
                $this->log_service->error($buffer);
            } else {
                $this->log_service->info($buffer);
            }
        });
    }
开发者ID:lightster,项目名称:dnsmasq-mgmt,代码行数:25,代码来源:ProcessService.php

示例7: report

 /**
  * @param Event $event
  */
 public static function report(Event $event)
 {
     $bin = self::getOption('phpcpd-bin', $event);
     $include = self::getOption('phpcpd-include', $event);
     $exclude = self::getOption('phpcpd-exclude', $event);
     $xmlReportFile = self::getOption('phpcpd-xml-report-file', $event);
     $minLines = self::getOption('phpcpd-min-lines', $event);
     $minTokens = self::getOption('phpcpd-min-tokens', $event);
     $failOnError = self::getOption('phpcpd-fail-on-error', $event);
     $logPrepend = self::getOption('phpcpd-log-prepend', $event);
     $command = array($bin, '--no-interaction', '--min-lines ' . $minLines, '--min-tokens ' . $minTokens);
     if ($xmlReportFile) {
         $command[] = '--log-pmd ' . self::getReportResultsPath($event) . '/' . $xmlReportFile;
     }
     if ($exclude) {
         $command[] = '--exclude ' . implode(' ', $exclude);
     }
     $command[] = implode(' ', $include);
     if (!$failOnError) {
         $command[] = '|| true';
     }
     $process = new Process(implode(' ', $command), null, null, null, null, []);
     $process->mustRun(function ($type, $buffer) use($event, $logPrepend) {
         self::writeProcessBuffer($type, $buffer, $event, $logPrepend);
     });
 }
开发者ID:javihgil,项目名称:composer-ci-tools,代码行数:29,代码来源:PhpCpd.php

示例8: mustRun

 public function mustRun($callback = null)
 {
     parent::mustRun($callback);
     // Check for problems with output.
     $this->checkOutputForProblems();
     return $this;
 }
开发者ID:gjb2048,项目名称:moodle-plugin-ci,代码行数:7,代码来源:MoodleProcess.php

示例9: runFix

 /**
  * @param string $path
  * @param Event  $event
  */
 protected static function runFix($path, Event $event)
 {
     $bin = self::getOption('phpcsfixer-bin', $event);
     $failOnError = self::getOption('phpcsfixer-fail-on-error', $event);
     $logPrepend = self::getOption('phpcsfixer-log-prepend', $event);
     $level = self::getOption('phpcsfixer-level', $event);
     $fixers = self::getOption('phpcsfixer-fixers', $event);
     $config = self::getOption('phpcsfixer-config', $event);
     $dryRun = self::getOption('phpcsfixer-dry-run', $event);
     $command = array($bin, 'fix', $path);
     if ($level) {
         $command[] = '--level=' . $level;
     }
     if (!empty($fixers) && is_array($fixers)) {
         $command[] = '--fixers=' . implode(',', $fixers);
     }
     if ($config) {
         $command[] = '--config=' . $config;
     }
     if ($dryRun === true) {
         $command[] = '--dry-run';
     }
     if (!$failOnError) {
         $command[] = '|| true';
     }
     $process = new Process(implode(' ', $command), null, null, null, null, []);
     $process->mustRun(function ($type, $buffer) use($event, $logPrepend) {
         self::writeProcessBuffer($type, $buffer, $event, $logPrepend);
     });
 }
开发者ID:javihgil,项目名称:composer-ci-tools,代码行数:34,代码来源:PhpCsFixer.php

示例10: report

 /**
  * @param Event $event
  */
 public static function report(Event $event)
 {
     $bin = self::getOption('phpcs-bin', $event);
     $include = self::getOption('phpcs-include', $event);
     $exclude = self::getOption('phpcs-exclude', $event);
     $report = self::getOption('phpcs-report', $event);
     $xmlReportFile = self::getOption('phpcs-xml-report-file', $event);
     $standard = self::getOption('phpcs-standard', $event);
     $failOnError = self::getOption('phpcs-fail-on-error', $event);
     $logPrepend = self::getOption('phpcs-log-prepend', $event);
     $command = array($bin, '--report=' . $report, '--standard=' . $standard);
     if ($xmlReportFile) {
         $command[] = '--report-file=' . self::getReportResultsPath($event) . '/' . $xmlReportFile;
     }
     if ($exclude) {
         $command[] = implode(' ', array_map(function ($element) {
             return '--ignore=' . $element;
         }, $exclude));
     }
     $command[] = implode(' ', $include);
     if (!$failOnError) {
         $command[] = '|| true';
     }
     $process = new Process(implode(' ', $command), null, null, null, null, []);
     $process->mustRun(function ($type, $buffer) use($event, $logPrepend) {
         self::writeProcessBuffer($type, $buffer, $event, $logPrepend);
     });
 }
开发者ID:javihgil,项目名称:composer-ci-tools,代码行数:31,代码来源:PhpCs.php

示例11: deploy

 /**
  *
  * @param Project $project
  * @return string
  * @throws DeployException
  */
 public function deploy(Project $project)
 {
     $path = sys_get_temp_dir() . '/AwesomeDeployer';
     $this->filesystem->mkdir($path);
     chdir($path);
     $process = new Process('git clone ' . $project->getRepo() . ' project');
     $process->mustRun();
     $out = $process->getOutput();
     $pathProject = $path . '/project';
     chdir($pathProject);
     $script = $project->getScript();
     if ($script !== null) {
         $script = new Process($script);
         $script->mustRun();
         $out .= $script->getOutput();
     }
     switch ($project->getStrategy()) {
         case Project::STRATEGY_FABRIC:
             $command = $project->getCommand();
             break;
         default:
             throw new DeployException('Strategy not supported');
     }
     $deployment = new Process($command);
     $deployment->mustRun();
     $this->filesystem->remove($path);
     $out .= $deployment->getOutput();
     return $out;
 }
开发者ID:valanz,项目名称:deploy,代码行数:35,代码来源:Deployer.php

示例12: execute

 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
     $process = $this->getHelper('process');
     $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
     if (!is_dir(Platform::rootDir() . '/docker/fg')) {
         $process->mustRun($output, ['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', Platform::rootDir() . '/docker/fg']);
     }
     if (!is_dir(Platform::rootDir() . '/docker/xhpfg')) {
         $process->mustRun($output, ['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', Platform::rootDir() . '/docker/xhpfg']);
     }
     $stack = StacksFactory::getStack(Platform::webDir());
     switch ($stack->type()) {
         case Stacks\Drupal::TYPE:
             $this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>");
             $patchProcess = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
             break;
         case Stacks\WordPress::TYPE:
             $this->stdOut->writeln("<comment>Patching WordPress for xhprof</comment>");
             $patchProcess = new Process('patch -p0 < ' . CLI_ROOT . '/resources/wordpress-enable-profiling.patch', Platform::webDir());
             break;
         default:
             throw new \Exception('Stack type not supported yet.');
     }
     $patchProcess->mustRun();
 }
开发者ID:mglaman,项目名称:platform-docker,代码行数:31,代码来源:SetupCommand.php

示例13: check

 /**
  * @param Event $event
  */
 public static function check(Event $event)
 {
     $logPrepend = self::getOption('security-checker-log-prepend', $event);
     $process = new Process(self::getOption('security-checker-bin', $event) . ' security:check composer.lock --ansi');
     $process->mustRun(function ($type, $buffer) use($event, $logPrepend) {
         self::writeProcessBuffer($type, $buffer, $event, $logPrepend);
     });
 }
开发者ID:javihgil,项目名称:composer-ci-tools,代码行数:11,代码来源:SecurityChecker.php

示例14: zip

 /**
  * @return string
  */
 public function zip($file = 'archive.zip')
 {
     $temporaryDir = $this->createTmpDirectory();
     $this->write($temporaryDir);
     $command = sprintf('zip -r "%s" "%s"', $file, $temporaryDir);
     $process = new Process($command);
     $process->mustRun();
 }
开发者ID:sdieunidou,项目名称:process-zip-archive,代码行数:11,代码来源:ArchiveManager.php

示例15: do

 public function do()
 {
     $commands = $this->commands();
     if (!empty($commands)) {
         $process = new Process(implode("\n", $commands));
         $process->mustRun();
         $this->io->writeln($process->getOutput());
     }
 }
开发者ID:redfrogevents,项目名称:spacewave,代码行数:9,代码来源:ProcessTaskTrait.php


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