本文整理汇总了PHP中Symfony\Component\Process\ProcessBuilder::getProcess方法的典型用法代码示例。如果您正苦于以下问题:PHP ProcessBuilder::getProcess方法的具体用法?PHP ProcessBuilder::getProcess怎么用?PHP ProcessBuilder::getProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\ProcessBuilder
的用法示例。
在下文中一共展示了ProcessBuilder::getProcess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildProcess
/**
* Build a Process to run tivodecode decoding a file with a MAK
*
* @param string $mak TiVo's Media Access Key
* @param string $input Where the encoded TiVo file is
* @param string $output Where the decoded MPEG file goes
*
* @return Process
*/
protected function buildProcess($mak, $input, $output)
{
$this->builder->setPrefix('/usr/local/bin/tivodecode');
$this->builder->setArguments([$input, '--mak=' . $mak, '--no-verify', '--out=' . $output]);
$this->builder->setTimeout(null);
return $this->builder->getProcess();
}
示例2: buildProcess
/**
* Build a Process to run avahi-browse looking for TiVo on TCP
*
* @return Process
*/
protected function buildProcess()
{
$this->builder->setPrefix('avahi-browse');
$this->builder->setArguments(['--ignore-local', '--resolve', '--terminate', '_tivo-videos._tcp']);
$this->builder->setTimeout(60);
return $this->builder->getProcess();
}
示例3: start
/**
* Asynchronously start mediainfo operation.
* Make call to MediaInfoCommandRunner::wait() afterwards to receive output.
*/
public function start()
{
$this->processBuilder->add($this->filePath);
$this->processAsync = $this->processBuilder->getProcess();
// just takes advantage of symfony's underlying Process framework
// process runs in background
$this->processAsync->start();
}
示例4: install
/**
* Function to install Laravel
*
* @return string directory where app was installed
*/
public function install()
{
$this->command->comment("Foreman", "Installing fresh Laravel app");
$this->builder->setPrefix('composer');
$this->builder->setArguments(['create-project', 'laravel/laravel', $this->appDir, '--prefer-dist']);
$this->builder->getProcess()->run();
$this->command->comment("Foreman", "Done, Laravel installed at: {$this->appDir}");
return $this->appDir;
}
示例5: run
/**
* @return string
*/
public function run()
{
$this->processBuilder->add($this->filePath);
$process = $this->processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
return $process->getOutput();
}
示例6: executeCommand
/**
* @return string
* @throws \RuntimeException
*/
protected function executeCommand()
{
$this->processBuilder->setArguments(array());
$this->processBuilder->add($this->filePath);
$process = $this->processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
return $process->getOutput();
}
示例7: getProp
/**
* Get a property from youtube-dl.
*
* @param string $url URL to parse
* @param string $format Format
* @param string $prop Property
*
* @return string
*/
private function getProp($url, $format = null, $prop = 'dump-json')
{
$this->procBuilder->setArguments(['--' . $prop, $url]);
if (isset($format)) {
$this->procBuilder->add('-f ' . $format);
}
$process = $this->procBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
throw new \Exception($process->getErrorOutput());
} else {
return $process->getOutput();
}
}
示例8: execute
/**
* Execute this task
*
* @param \TYPO3\Surf\Domain\Model\Node $node
* @param \TYPO3\Surf\Domain\Model\Application $application
* @param \TYPO3\Surf\Domain\Model\Deployment $deployment
* @param array $options
* @throws \TYPO3\Surf\Exception\InvalidConfigurationException
* @return void
*/
public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
{
$this->assertRequiredOptionsExist($options);
$dumpCommand = new ProcessBuilder();
$dumpCommand->setPrefix('mysqldump');
$dumpCommand->setArguments(array('-h', $options['sourceHost'], '-u', $options['sourceUser'], '-p' . $options['sourcePassword'], $options['sourceDatabase']));
$mysqlCommand = new ProcessBuilder();
$mysqlCommand->setPrefix('mysql');
$mysqlCommand->setArguments(array('-h', $options['targetHost'], '-u', $options['targetUser'], '-p' . $options['targetPassword'], $options['targetDatabase']));
$arguments = array();
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$arguments[] = $username . $hostname;
if ($node->hasOption('port')) {
$arguments[] = '-P';
$arguments[] = $node->getOption('port');
}
$arguments[] = $mysqlCommand->getProcess()->getCommandLine();
$sshCommand = new ProcessBuilder();
$sshCommand->setPrefix('ssh');
$sshCommand->setArguments($arguments);
$command = $dumpCommand->getProcess()->getCommandLine() . ' | ' . $sshCommand->getProcess()->getCommandLine();
$localhost = new Node('localhost');
$localhost->setHostname('localhost');
$this->shell->executeOrSimulate($command, $localhost, $deployment);
}
示例9: processWithConfiguration
/**
* @param BinaryInterface $binary
* @param array $options
*
* @throws ProcessFailedException
*
* @return BinaryInterface
*/
public function processWithConfiguration(BinaryInterface $binary, array $options)
{
$type = strtolower($binary->getMimeType());
if (!in_array($type, array('image/jpeg', 'image/jpg'))) {
return $binary;
}
$pb = new ProcessBuilder(array($this->mozjpegBin));
// Places emphasis on DC
$pb->add('-quant-table');
$pb->add(2);
$transformQuality = array_key_exists('quality', $options) ? $options['quality'] : $this->quality;
if ($transformQuality !== null) {
$pb->add('-quality');
$pb->add($transformQuality);
}
$pb->add('-optimise');
// Favor stdin/stdout so we don't waste time creating a new file.
$pb->setInput($binary->getContent());
$proc = $pb->getProcess();
$proc->run();
if (false !== strpos($proc->getOutput(), 'ERROR') || 0 !== $proc->getExitCode()) {
throw new ProcessFailedException($proc);
}
$result = new Binary($proc->getOutput(), $binary->getMimeType(), $binary->getFormat());
return $result;
}
示例10: run
/**
* @throws PhpCsFixerException
*/
public function run()
{
foreach ($this->levels as $level => $value) {
if (true === $value) {
$this->outputHandler->setTitle('Checking ' . strtoupper($level) . ' code style with PHP-CS-FIXER');
$this->output->write($this->outputHandler->getTitle());
$errors = array();
foreach ($this->files as $file) {
$srcFile = preg_match($this->filesToAnalyze, $file);
if (!$srcFile) {
continue;
}
$processBuilder = new ProcessBuilder(array('php', 'bin/php-cs-fixer', '--dry-run', 'fix', $file, '--level=' . $level));
$phpCsFixer = $processBuilder->getProcess();
$phpCsFixer->run();
if (false === $phpCsFixer->isSuccessful()) {
$errors[] = $phpCsFixer->getOutput();
}
}
if ($errors) {
$this->output->writeln(BadJobLogo::paint());
throw new PhpCsFixerException(implode('', $errors));
}
$this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
}
}
}
示例11: analyze
/**
* {@inheritdoc}
*/
public function analyze($analyzedFileName = null)
{
$result = new \SCQAT\Result();
$processBuilder = new ProcessBuilder(array($this->language->configuration["command"], $this->context->vendorDirectory . "bin/php-cs-fixer", "--level=psr2", "--dry-run", "--verbose", "fix", $analyzedFileName));
$process = $processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
$result->isSuccess = false;
$result->value = "KO";
$description = "";
$outputLines = explode("\n", trim($process->getOutput()));
foreach ($outputLines as $line) {
// remove all output useless lines
if (strpos($line, $analyzedFileName) !== false) {
// remove filename and useles chars to just keep fixers violated
$description = trim(substr($line, strpos($line, $analyzedFileName) + strlen($analyzedFileName)), " ()");
}
}
$result->description = "Triggered fixers : " . $description;
} else {
$result->isSuccess = true;
$result->value = "OK";
}
return $result;
}
示例12: runCommand
protected function runCommand($cmd)
{
$builder = new ProcessBuilder($cmd);
$process = $builder->getProcess();
$process->run();
return $process->getOutput();
}
示例13: format
/**
* {@inheritDoc}
*/
public function format($string)
{
static $format = <<<EOF
package main
import "fmt"
import "github.com/russross/blackfriday"
func main() {
input := []byte("%s")
output := blackfriday.MarkdownCommon(input)
fmt.Printf(string(output[:]))
}
EOF;
$input = tempnam(sys_get_temp_dir(), 'fabricius_blackfriday');
$input .= '.go';
file_put_contents($input, sprintf($format, addcslashes($string, "\n\"")));
$pb = new ProcessBuilder(array($this->goBin, 'run', $input));
$proc = $pb->getProcess();
$code = $proc->run();
unlink($input);
if (0 !== $code) {
$message = sprintf("An error occurred while running:\n%s", $proc->getCommandLine());
$errorOutput = $proc->getErrorOutput();
if (!empty($errorOutput)) {
$message .= "\n\nError Output:\n" . str_replace("\r", '', $errorOutput);
}
$output = $proc->getOutput();
if (!empty($output)) {
$message .= "\n\nOutput:\n" . str_replace("\r", '', $output);
}
throw new RuntimeException($message);
}
return $proc->getOutput();
}
示例14: execute
/**
* @param string $file
*
* @return Process
*/
private function execute($file)
{
$processBuilder = new ProcessBuilder(['php', '-l', $file]);
$process = $processBuilder->getProcess();
$process->run();
return $process;
}
示例15: execute
/**
* @param string $file
* @param string $standard
*
* @return Process
*/
private function execute($file, $standard)
{
$processBuilder = new ProcessBuilder(['php', $this->toolPathFinder->find('phpcs'), '--standard=' . $standard, $file]);
$process = $processBuilder->getProcess();
$process->run();
return $process;
}