當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。