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


PHP ProcessExecutor::execute方法代码示例

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


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

示例1: executeCommand

 /**
  * Executes a shell command with escaping.
  *
  * @param string $cmd
  * @return bool
  */
 protected function executeCommand($cmd)
 {
     // Shell-escape all arguments except the command.
     $args = func_get_args();
     foreach ($args as $index => $arg) {
         if ($index !== 0) {
             $args[$index] = escapeshellarg($arg);
         }
     }
     // And replace the arguments.
     $command = call_user_func_array('sprintf', $args);
     $output = '';
     if ($this->io->isVerbose()) {
         $this->io->write('<comment>' . $command . '</comment>');
         $io = $this->io;
         $output = function ($type, $data) use($io) {
             if ($type == Process::ERR) {
                 $io->write('<error>' . $data . '</error>');
             } else {
                 $io->write('<comment>' . $data . '</comment>');
             }
         };
     }
     return $this->executor->execute($command, $output) == 0;
 }
开发者ID:pingers,项目名称:composer-patches,代码行数:31,代码来源:Patches.php

示例2: guessSvnVersion

 private function guessSvnVersion(array $packageConfig, $path)
 {
     SvnUtil::cleanEnv();
     // try to fetch current version from svn
     if (0 === $this->process->execute('svn info --xml', $output, $path)) {
         $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
         $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
         $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
         $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
         if (preg_match($urlPattern, $output, $matches)) {
             if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
                 // we are in a branches path
                 $version = $this->versionParser->normalizeBranch($matches[3]);
                 $prettyVersion = 'dev-' . $matches[3];
                 if ('9999999-dev' === $version) {
                     $version = $prettyVersion;
                 }
                 return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
             }
             $prettyVersion = trim($matches[1]);
             $version = $this->versionParser->normalize($prettyVersion);
             return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
         }
     }
 }
开发者ID:neon64,项目名称:composer,代码行数:25,代码来源:VersionGuesser.php

示例3: initialize

 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     foreach ($this->getUrlMatches() as $url) {
         $path = realpath($url) . DIRECTORY_SEPARATOR;
         $composerFilePath = $path . 'composer.json';
         if (!file_exists($composerFilePath)) {
             continue;
         }
         $json = file_get_contents($composerFilePath);
         $package = JsonFile::parseJson($json, $composerFilePath);
         $package['dist'] = array('type' => 'path', 'url' => $url, 'reference' => '');
         if (!isset($package['version'])) {
             $package['version'] = $this->versionGuesser->guessVersion($package, $path) ?: 'dev-master';
         }
         $output = '';
         if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
             $package['dist']['reference'] = trim($output);
         } else {
             $package['dist']['reference'] = Locker::getContentHash($json);
         }
         $package = $this->loader->load($package);
         $this->addPackage($package);
     }
     if (count($this->getPackages()) == 0) {
         throw new \RuntimeException(sprintf('No `composer.json` file found in any path repository in "%s"', $this->url));
     }
 }
开发者ID:AppChecker,项目名称:composer,代码行数:33,代码来源:PathRepository.php

示例4: initialize

 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     foreach ($this->getUrlMatches() as $url) {
         $path = realpath($url) . DIRECTORY_SEPARATOR;
         $composerFilePath = $path . 'composer.json';
         if (!file_exists($composerFilePath)) {
             continue;
         }
         $json = file_get_contents($composerFilePath);
         $package = JsonFile::parseJson($json, $composerFilePath);
         $package['dist'] = array('type' => 'path', 'url' => $url, 'reference' => sha1($json));
         $package['transport-options'] = $this->options;
         if (!isset($package['version'])) {
             $versionData = $this->versionGuesser->guessVersion($package, $path);
             $package['version'] = $versionData['version'] ?: 'dev-master';
         }
         $output = '';
         if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
             $package['dist']['reference'] = trim($output);
         }
         $package = $this->loader->load($package);
         $this->addPackage($package);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:PathRepository.php

示例5: installDependencies

 private static function installDependencies(IOInterface $io, $folder)
 {
     $io->write("[0;32mInstalling front end dependencies from package.json[0m");
     $proc = new ProcessExecutor();
     $proc->execute('cd ' . $folder . ' && npm install');
     $io->write("[0;32mFront end dependencies installed[0m");
 }
开发者ID:studionone,项目名称:Flint,代码行数:7,代码来源:NpmBridge.php

示例6: testExecuteOutputsIfNotCaptured

 public function testExecuteOutputsIfNotCaptured()
 {
     $process = new ProcessExecutor();
     ob_start();
     $process->execute('echo foo');
     $output = ob_get_clean();
     $this->assertEquals("foo" . PHP_EOL, $output);
 }
开发者ID:natxet,项目名称:composer,代码行数:8,代码来源:ProcessExecutorTest.php

示例7: checkGit

 private function checkGit()
 {
     $this->process->execute('git config color.ui', $output);
     if (strtolower(trim($output)) === 'always') {
         return '<comment>Your git color.ui setting is set to always, this is known to create issues. Use "git config --global color.ui true" to set it correctly.</comment>';
     }
     return true;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:8,代码来源:DiagnoseCommand.php

示例8: throwException

 private function throwException($message, $url)
 {
     // git might delete a directory when it fails and php will not know
     clearstatcache();
     if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
         throw new \RuntimeException('Failed to clone ' . self::sanitizeUrl($url) . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
     }
     throw new \RuntimeException($message);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:Git.php

示例9: addComposerTime

 /**
  * Add time in composer.
  *
  * @param array           $composer
  * @param ProcessExecutor $process
  * @param string          $cmd
  * @param string          $repoDir
  * @param string          $datetimePrefix
  *
  * @return array The composer
  */
 protected static function addComposerTime(array $composer, ProcessExecutor $process, $cmd, $repoDir, $datetimePrefix = '')
 {
     if (!isset($composer['time'])) {
         $process->execute($cmd, $output, $repoDir);
         $date = new \DateTime($datetimePrefix . trim($output), new \DateTimeZone('UTC'));
         $composer['time'] = $date->format('Y-m-d H:i:s');
     }
     return $composer;
 }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:20,代码来源:ProcessUtil.php

示例10: getVersion

 /**
  * Retrieves the current git version.
  *
  * @return string|null The git version number.
  */
 public function getVersion()
 {
     if (isset(self::$version)) {
         return self::$version;
     }
     if (0 !== $this->process->execute('git --version', $output)) {
         return;
     }
     if (preg_match('/^git version (\\d+(?:\\.\\d+)+)/m', $output, $matches)) {
         return self::$version = $matches[1];
     }
 }
开发者ID:neon64,项目名称:composer,代码行数:17,代码来源:Git.php

示例11: determineLocalPackageReference

 private function determineLocalPackageReference()
 {
     $basePath = realpath(getcwd());
     if (is_dir($basePath . DIRECTORY_SEPARATOR . '.git')) {
         $process = new ProcessExecutor();
         if ($process->execute('git rev-parse HEAD', $output, $basePath) === 0) {
             return trim($output);
         }
     }
     // TODO: add support for other VCS'es
     return null;
 }
开发者ID:mcuelenaere,项目名称:composer-revision-plugin,代码行数:12,代码来源:Plugin.php

示例12: applyPatches

 public function applyPatches()
 {
     if (!is_dir($this->patchDir) && is_dir($this->patchDir)) {
         return;
     }
     $patches = glob($this->patchDir . '/*.patch');
     if (count($patches)) {
         $io = $this->io;
         $handler = function ($type, $data) use($io) {
             if ($type == Process::ERR) {
                 $io->write('<error>' . $data . '</error>');
             } else {
                 $io->write('<info>' . $data . '</info>');
             }
         };
         foreach ($patches as $patchFile) {
             $file = escapeshellarg($patchFile);
             $io->write("<comment>Applying patches from {$file}.</comment>");
             $this->executor->execute("patch -r - -p0 --no-backup-if-mismatch -i " . $file, $handler);
         }
     }
 }
开发者ID:Marketo,项目名称:Composer-Patch-Applicator,代码行数:22,代码来源:ApplyPatches.php

示例13: execute

 /**
  * Execute an SVN command and try to fix up the process with credentials
  * if necessary.
  *
  * @param string  $command SVN command to run
  * @param string  $url     SVN url
  * @param string  $cwd     Working directory
  * @param string  $path    Target for a checkout
  * @param Boolean $verbose Output all output to the user
  *
  * @return string
  *
  * @throws \RuntimeException
  */
 public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
 {
     $svnCommand = $this->getCommand($command, $url, $path);
     $output = null;
     $io = $this->io;
     $handler = function ($type, $buffer) use(&$output, $io, $verbose) {
         if ($type !== 'out') {
             return;
         }
         $output .= $buffer;
         if ($verbose) {
             $io->write($buffer, false);
         }
     };
     $status = $this->process->execute($svnCommand, $handler, $cwd);
     if (0 === $status) {
         return $output;
     }
     if (empty($output)) {
         $output = $this->process->getErrorOutput();
     }
     // the error is not auth-related
     if (false === stripos($output, 'authorization failed:')) {
         throw new \RuntimeException($output);
     }
     // no auth supported for non interactive calls
     if (!$this->io->isInteractive()) {
         throw new \RuntimeException('can not ask for authentication in non interactive mode (' . $output . ')');
     }
     // TODO keep a count of user auth attempts and ask 5 times before
     // failing hard (currently it fails hard directly if the URL has credentials)
     // try to authenticate
     if (!$this->hasAuth()) {
         $this->doAuthDance();
         // restart the process
         return $this->execute($command, $url, $cwd, $path, $verbose);
     }
     throw new \RuntimeException('wrong credentials provided (' . $output . ')');
 }
开发者ID:romainneutron,项目名称:composer,代码行数:53,代码来源:Svn.php

示例14: getRemovedFiles

 /**
  * Retrieve removed files list between two package versions
  *
  * @param PackageInterface $targert new package version to install
  * @param PackageInterface $initial previous package version
  *
  * @return array
  */
 protected function getRemovedFiles(PackageInterface $target, PackageInterface $initial)
 {
     $output = false;
     $removedFiles = array();
     if ($initial->getSourceReference() != $target->getSourceReference()) {
         if ($this->io->isVerbose()) {
             $this->io->write("Retrieving list of removed files from previous version installed.");
         }
         $command = sprintf('git diff --name-only --diff-filter=D %s %s', $initial->getSourceReference(), $target->getSourceReference());
         if (0 !== $this->process->execute($command, $output, $this->rubedoRootDir)) {
             throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
         }
         $removedFiles = explode(PHP_EOL, ltrim(rtrim($output)));
     }
     return $removedFiles;
 }
开发者ID:novactive,项目名称:rubedo-core-installer,代码行数:24,代码来源:CoreInstaller.php

示例15: executeCommand

 /**
  * Executes a shell command
  *
  * @param  string $command the command to execute
  * @param  mixed  $output  the output will be written into this var if passed by ref
  *                         if a callable is passed it will be used as output handler
  * @param  string $cwd     the working directory
  * @return bool
  */
 protected function executeCommand($command, &$output = null, $cwd = null)
 {
     $success = $this->executor->execute($command, $output, $cwd) == 0;
     if ($this->io->isVerbose()) {
         $this->io->write('<comment>' . $command . '</comment>');
         $io = $this->io;
         $output = function ($type, $data) use($io) {
             if ($type == Process::ERR) {
                 $io->write('<error>' . $data . '</error>');
             } else {
                 $io->write('<comment>' . $data . '</comment>');
             }
         };
     }
     return $success;
 }
开发者ID:skwashd,项目名称:composer-patches,代码行数:25,代码来源:Patches.php


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