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


PHP ProcessBuilder::setWorkingDirectory方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param GitRepository $repository The git repository to work on.
  */
 public function __construct(GitRepository $repository)
 {
     $this->repository = $repository;
     $this->processBuilder = new ProcessBuilder();
     $this->processBuilder->setWorkingDirectory($repository->getRepositoryPath());
     $this->processBuilder->add($this->repository->getConfig()->getGitExecutablePath());
     $this->initializeProcessBuilder();
 }
开发者ID:bit3,项目名称:git-php,代码行数:13,代码来源:AbstractCommandBuilder.php

示例2: 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";
 }
开发者ID:mangareader,项目名称:laravel-ansible,代码行数:32,代码来源:runAnsible.php

示例3: startProcess

 /**
  * Creates the given process
  *
  * @throws \Exception
  */
 private function startProcess(OutputInterface $output)
 {
     $arguments = $this->resolveProcessArgs();
     $name = sha1(serialize($arguments));
     if ($this->background->hasProcess($name)) {
         throw new \RuntimeException("Service is already running.");
     }
     $builder = new ProcessBuilder($arguments);
     if ($this->hasParameter('cwd')) {
         $builder->setWorkingDirectory($this->getParameter('cwd'));
     }
     $process = $builder->getProcess();
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $output->writeln($process->getCommandLine());
     }
     if ($this->hasParameter('output')) {
         $append = $this->hasParameter('append') && $this->getParameter('append') ? 'a' : 'w';
         $stream = fopen($this->getParameter('output'), $append);
         $output = new StreamOutput($stream, StreamOutput::VERBOSITY_NORMAL, true);
     }
     $process->start(function ($type, $buffer) use($output) {
         $output->write($buffer);
     });
     $this->background->addProcess($name, $process);
     if (!in_array($process->getExitCode(), $this->getParameter('successCodes'))) {
         throw new TaskRuntimeException($this->getName(), $process->getErrorOutput());
     }
 }
开发者ID:kangkot,项目名称:bldr,代码行数:33,代码来源:BackgroundTask.php

示例4: isTracked

 /**
  * {@inheritdoc}
  */
 public function isTracked($file)
 {
     $processBuilder = new ProcessBuilder([$this->binaryPath, 'locate', $file]);
     $processBuilder->setWorkingDirectory($this->root);
     $process = $processBuilder->getProcess();
     $process->run();
     return $process->isSuccessful();
 }
开发者ID:tripomatic,项目名称:php-code-quality,代码行数:11,代码来源:MercurialAdapter.php

示例5: __destruct

 public function __destruct()
 {
     if ($this->temp !== null) {
         $processBuilder = new ProcessBuilder(['rm', '-rf', $this->temp]);
         $processBuilder->setWorkingDirectory($this->root);
         $process = $processBuilder->getProcess();
         $process->run();
     }
 }
开发者ID:tripomatic,项目名称:php-code-quality,代码行数:9,代码来源:GitAdapter.php

示例6: migrationCommandBuilder

 /**
  * Returns ProcessBuilder instance with predefined process command for migration command execution.
  *
  * @return \Symfony\Component\Process\ProcessBuilder
  */
 private function migrationCommandBuilder($migrationPath = '', $migrationTable = '{{%migration}}', $down = false)
 {
     $builder = new ProcessBuilder();
     $builder->setWorkingDirectory(Yii::getAlias('@app'))->setPrefix($this->getPhpExecutable())->setArguments([realpath(Yii::getAlias('@app') . '/yii'), 'migrate/' . ($down ? 'down' : 'up'), '--color=0', '--interactive=0', '--migrationTable=' . $migrationTable, $down ? 65536 : 0]);
     if (empty($migrationPath) === false) {
         $builder->add('--migrationPath=' . $migrationPath);
     }
     return $builder;
 }
开发者ID:heartshare,项目名称:dotplant2,代码行数:14,代码来源:UpdateHelper.php

示例7: createProcess

 /**
  * @param array $commands
  * @param \Hshn\NpmBundle\Npm\ConfigurationInterface $configuration
  * @return \Symfony\Component\Process\Process
  */
 private function createProcess(array $commands, ConfigurationInterface $configuration)
 {
     $builder = new ProcessBuilder([$this->binPath]);
     $builder->setWorkingDirectory($configuration->getDirectory());
     $builder->setTimeout(600);
     foreach ($commands as $command) {
         $builder->add($command);
     }
     return $builder->getProcess();
 }
开发者ID:hshn,项目名称:HshnNpmBundle,代码行数:15,代码来源:Npm.php

示例8: getProcess

 protected function getProcess($drupal, $dsn)
 {
     $builder = new ProcessBuilder();
     $builder->inheritEnvironmentVariables(true);
     $builder->setWorkingDirectory($drupal);
     $builder->setPrefix('php');
     $builder->setArguments(array('-d sendmail_path=`which true`', $this->drush, 'site-install', 'standard', "--db-url={$dsn}", '-y'));
     $process = $builder->getProcess();
     return $process;
 }
开发者ID:korstiaan,项目名称:drunit,代码行数:10,代码来源:Installer.php

示例9: getProcessBuilder

 /**
  * {@inheritdoc}
  */
 public function getProcessBuilder(array $arguments, $timeout = self::DEFAULT_PROCESS_TIMEOUT)
 {
     $builder = new ProcessBuilder();
     $builder->setPrefix($this->getPhpBinary());
     $builder->setWorkingDirectory($this->getCwd());
     $builder->setArguments($arguments);
     $builder->setTimeout($timeout);
     $builder->inheritEnvironmentVariables(true);
     return $builder;
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:13,代码来源:EnvironmentHelper.php

示例10: sortUseStatements

 /**
  * Executes the Marc Morera's PHP-Formatter sort use statements command.
  *
  * @param array $parameters The project parameters
  *
  * @throws \LIN3S\CS\Exception\CheckFailException
  */
 private static function sortUseStatements($parameters)
 {
     $processBuilder = new ProcessBuilder(['php', 'vendor/mmoreram/php-formatter/bin/php-formatter', 'formatter:use:sort', $parameters['phpformatter_path']]);
     $processBuilder->setWorkingDirectory($parameters['root_directory']);
     $process = $processBuilder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new CheckFailException('PHP Formatter', 'Something fails during php formatter\'s sort uses process');
     }
 }
开发者ID:lin3s,项目名称:cs,代码行数:17,代码来源:PhpFormatter.php

示例11: startWebServer

 private function startWebServer(InputInterface $input, OutputInterface $output, $targetDirectory)
 {
     $builder = new ProcessBuilder([PHP_BINARY, '-S', $input->getArgument('address')]);
     $builder->setWorkingDirectory($targetDirectory);
     $builder->setTimeout(null);
     $process = $builder->getProcess();
     $process->start();
     $output->writeln(sprintf("Server running on <comment>%s</comment>", $input->getArgument('address')));
     return $process;
 }
开发者ID:snipe,项目名称:Couscous,代码行数:10,代码来源:PreviewCommand.php

示例12: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
     $builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address')));
     $builder->setWorkingDirectory($input->getOption('web-dir'));
     $builder->setTimeout(null);
     $builder->getProcess()->mustRun(function ($type, $buffer) use($output) {
         if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
             $output->write($buffer);
         }
     });
 }
开发者ID:carew,项目名称:carew,代码行数:12,代码来源:Serve.php

示例13: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf("Server running on <info>%s</info>\n", $input->getArgument('address')));
     $builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), __DIR__ . '/../../../src/router.php'));
     $builder->setWorkingDirectory($input->getOption('docroot'));
     $builder->setTimeout(null);
     $builder->getProcess()->run(function ($type, $buffer) use($output) {
         if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
             $output->write($buffer);
         }
     });
 }
开发者ID:ubermuda,项目名称:concerto,代码行数:15,代码来源:ServerRunCommand.php

示例14: execute

 protected function execute($arguments)
 {
     array_unshift($arguments, $this->gitPath);
     $builder = new ProcessBuilder($arguments);
     $builder->setWorkingDirectory($this->repo);
     $process = $builder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('Unable to run the command (%s).', $process->getErrorOutput()));
     }
     return $process->getOutput();
 }
开发者ID:remiheens,项目名称:dbbalancer,代码行数:12,代码来源:GitVersionCollection.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $router = $input->getOption('router') ?: $this->getContainer()->get('kernel')->locateResource('@FrameworkBundle/Resources/config/router.php');
     $output->writeln(sprintf("Server running on <info>%s</info>\n", $input->getArgument('address')));
     $builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
     $builder->setWorkingDirectory($input->getOption('docroot'));
     $builder->setTimeout(null);
     $builder->getProcess()->run(function ($type, $buffer) use($output) {
         if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
             $output->write($buffer);
         }
     });
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:16,代码来源:ServerRunCommand.php


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