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


PHP Util\ProcessExecutor类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: extract

 protected function extract($file, $path)
 {
     $processError = null;
     // Try to use unrar on *nix
     if (!Platform::isWindows()) {
         $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
         if (0 === $this->process->execute($command, $ignoredOutput)) {
             return;
         }
         $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
     }
     if (!class_exists('RarArchive')) {
         // php.ini path is added to the error message to help users find the correct file
         $iniMessage = IniHelper::getMessage();
         $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n" . $iniMessage . "\n" . $processError;
         if (!Platform::isWindows()) {
             $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
         }
         throw new \RuntimeException($error);
     }
     $rarArchive = RarArchive::open($file);
     if (false === $rarArchive) {
         throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
     }
     $entries = $rarArchive->getEntries();
     if (false === $entries) {
         throw new \RuntimeException('Could not retrieve RAR archive entries');
     }
     foreach ($entries as $entry) {
         if (false === $entry->extract($path)) {
             throw new \RuntimeException('Could not extract entry');
         }
     }
     $rarArchive->close();
 }
开发者ID:Rudloff,项目名称:composer,代码行数:35,代码来源:RarDownloader.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('list')) {
         return $this->listScripts();
     } elseif (!$input->getArgument('script')) {
         throw new \RunTimeException('Missing required argument "script"');
     }
     $script = $input->getArgument('script');
     if (!in_array($script, $this->scriptEvents)) {
         if (defined('Composer\\Script\\ScriptEvents::' . str_replace('-', '_', strtoupper($script)))) {
             throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
         }
     }
     $composer = $this->getComposer();
     $hasListeners = $composer->getEventDispatcher()->hasEventListeners(new CommandEvent($script, $composer, $this->getIO()));
     if (!$hasListeners) {
         throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
     }
     $args = $input->getArgument('args');
     if (!is_null($timeout = $input->getOption('timeout'))) {
         if (!ctype_digit($timeout)) {
             throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
         }
         // Override global timeout set before in Composer by environment or config
         ProcessExecutor::setTimeout((int) $timeout);
     }
     return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args);
 }
开发者ID:alcaeus,项目名称:composer,代码行数:28,代码来源:RunScriptCommand.php

示例6: get

 protected function get($originUrl, $fileUrl, $options = [], $fileName = null, $progress = true)
 {
     if (strpos($fileUrl, 'ssh://') !== 0) {
         throw new \UnexpectedValueException("This does not appear to be a file that should be downloaded via ssh: {$fileUrl}");
     }
     // strip off the pseudo protocol
     $fileUrl = substr($fileUrl, 6);
     if ($this->io->isVerbose()) {
         $this->io->write("Downloading {$fileUrl} via ssh.");
     }
     // filename means we want to save
     if ($fileName) {
         $cmd = 'scp ' . ProcessExecutor::escape($fileUrl) . ' ' . ProcessExecutor::escape($fileName);
     } else {
         // otherwise just return the file contents
         list($host, $path) = explode(':', $fileUrl);
         $cmd = 'ssh ' . ProcessExecutor::escape($host) . ' ' . ProcessExecutor::escape('cat ' . ProcessExecutor::escape($path));
     }
     if ($progress) {
         $this->io->writeError('    Downloading: <comment>Connecting...</comment>', false);
     }
     // success?
     // @todo: do we need to catch any exceptions here?
     if ($this->process->execute($cmd, $output) === 0) {
         if ($progress) {
             $this->io->overwriteError('    Downloading: <comment>100%</comment>');
         }
         return $output;
     } else {
         // some sort of error - boo!
         throw new \RuntimeException("Could not download {$fileUrl}. " . $process->getErrorOutput());
     }
 }
开发者ID:balbuf,项目名称:composer-wp,代码行数:33,代码来源:SSHFilesystem.php

示例7: loadConfiguration

 /**
  * {@inheritDoc}
  */
 public function loadConfiguration(Config $config)
 {
     // reload oauth token from config if available
     if ($tokens = $config->get('github-oauth')) {
         foreach ($tokens as $domain => $token) {
             if (!preg_match('{^[a-z0-9]+$}', $token)) {
                 throw new \UnexpectedValueException('Your github oauth token for ' . $domain . ' contains invalid characters: "' . $token . '"');
             }
             $this->setAuthentication($domain, $token, 'x-oauth-basic');
         }
     }
     if ($tokens = $config->get('gitlab-oauth')) {
         foreach ($tokens as $domain => $token) {
             $this->setAuthentication($domain, $token, 'oauth2');
         }
     }
     // reload http basic credentials from config if available
     if ($creds = $config->get('http-basic')) {
         foreach ($creds as $domain => $cred) {
             $this->setAuthentication($domain, $cred['username'], $cred['password']);
         }
     }
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
 }
开发者ID:alancleaver,项目名称:composer,代码行数:28,代码来源:BaseIO.php

示例8: extract

 protected function extract($file, $path)
 {
     $processError = null;
     if (self::$hasSystemUnzip && !(class_exists('ZipArchive') && Platform::isWindows())) {
         $command = 'unzip ' . ProcessExecutor::escape($file) . ' -d ' . ProcessExecutor::escape($path);
         if (!Platform::isWindows()) {
             $command .= ' && chmod -R u+w ' . ProcessExecutor::escape($path);
         }
         try {
             if (0 === $this->process->execute($command, $ignoredOutput)) {
                 return;
             }
             $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
         } catch (\Exception $e) {
             $processError = 'Failed to execute ' . $command . "\n\n" . $e->getMessage();
         }
         if (!class_exists('ZipArchive')) {
             throw new \RuntimeException($processError);
         }
     }
     $zipArchive = new ZipArchive();
     if (true !== ($retval = $zipArchive->open($file))) {
         throw new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file) . "\n" . $processError), $retval);
     }
     if (true !== $zipArchive->extractTo($path)) {
         throw new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n" . $processError));
     }
     $zipArchive->close();
 }
开发者ID:neon64,项目名称:composer,代码行数:29,代码来源:ZipDownloader.php

示例9: deployLibraries

 /**
  * Moves front-end libraries to Lightning's installed directory.
  *
  * @param \Composer\Script\Event $event
  *   The script event.
  */
 public static function deployLibraries(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (isset($extra['installer-paths'])) {
         foreach ($extra['installer-paths'] as $path => $criteria) {
             if (array_intersect(['drupal/lightning', 'type:drupal-profile'], $criteria)) {
                 $lightning = $path;
             }
         }
         if (isset($lightning)) {
             $lightning = str_replace('{$name}', 'lightning', $lightning);
             $executor = new ProcessExecutor($event->getIO());
             $output = NULL;
             $executor->execute('npm run install-libraries', $output, $lightning);
         }
     }
 }
开发者ID:sgrichards,项目名称:drupal-startup,代码行数:23,代码来源:ScriptHandler.php

示例10: createComposer

 /**
  * Creates a Composer instance
  *
  * @param IOInterface $io IO instance
  * @param mixed $localConfig either a configuration array or a filename to read from, if null it will read from the default filename
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null)
 {
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = getenv('COMPOSER') ?: 'composer.json';
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, new RemoteFilesystem($io));
         if (!$file->exists()) {
             if ($localConfig === 'composer.json') {
                 $message = 'Composer could not find a composer.json file in ' . getcwd();
             } else {
                 $message = 'Composer could not find the config file: ' . $localConfig;
             }
             $instructions = 'To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section';
             throw new \InvalidArgumentException($message . PHP_EOL . $instructions);
         }
         $file->validateSchema(JsonFile::LAX_SCHEMA);
         $localConfig = $file->read();
     }
     // Configuration defaults
     $config = $this->createConfig();
     $config->merge($localConfig);
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
     // initialize repository manager
     $rm = $this->createRepositoryManager($io, $config);
     // load default repository unless it's explicitly disabled
     $localConfig = $this->addPackagistRepository($localConfig);
     // load local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $loader = new Package\Loader\RootPackageLoader($rm);
     $package = $loader->load($localConfig);
     // initialize download manager
     $dm = $this->createDownloadManager($io);
     // initialize installation manager
     $im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir, $io);
     // purge packages if they have been deleted on the filesystem
     $this->purgePackages($rm, $im);
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setDownloadManager($dm);
     $composer->setInstallationManager($im);
     // init locker if possible
     if (isset($composerFile)) {
         $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
         $locker = new Package\Locker(new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:nlegoff,项目名称:composer,代码行数:65,代码来源:Factory.php

示例11: extract

 protected function extract($file, $path)
 {
     $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
     if (0 === $this->process->execute($command, $ignoredOutput)) {
         return;
     }
     $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
     throw new \RuntimeException($processError);
 }
开发者ID:neon64,项目名称:composer,代码行数:9,代码来源:XzDownloader.php

示例12: extract

 protected function extract($file, $path)
 {
     // we must use cmdline tar, as PharData::extract() messes up symlinks
     $command = 'tar -xzf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
     if (0 === $this->process->execute($command, $ignoredOutput)) {
         return;
     }
     throw new \RuntimeException("Failed to execute '{$command}'\n\n" . $this->process->getErrorOutput());
 }
开发者ID:tam-bourine,项目名称:heroku-buildpack-php,代码行数:9,代码来源:Downloader.php

示例13: 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

示例14: 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

示例15: 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


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