當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PackageInterface::getDistUrls方法代碼示例

本文整理匯總了PHP中Composer\Package\PackageInterface::getDistUrls方法的典型用法代碼示例。如果您正苦於以下問題:PHP PackageInterface::getDistUrls方法的具體用法?PHP PackageInterface::getDistUrls怎麽用?PHP PackageInterface::getDistUrls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Package\PackageInterface的用法示例。


在下文中一共展示了PackageInterface::getDistUrls方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: download

 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (!$package->getDistUrl()) {
         throw new \InvalidArgumentException('The given package is missing url information');
     }
     $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
     $urls = $package->getDistUrls();
     while ($url = array_shift($urls)) {
         try {
             return $this->doDownload($package, $path, $url);
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->writeError('');
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getCode() . ': ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('');
                 $this->io->writeError('    Failed, trying the next URL (' . $e->getCode() . ': ' . $e->getMessage() . ')');
             }
             if (!count($urls)) {
                 throw $e;
             }
         }
     }
     $this->io->writeError('');
 }
開發者ID:alcaeus,項目名稱:composer,代碼行數:28,代碼來源:FileDownloader.php

示例2: download

 public function download(PackageInterface $package, $path)
 {
     $temporaryDir = $this->config->get('vendor-dir') . '/composer/' . substr(md5(uniqid('', true)), 0, 8);
     $this->filesystem->ensureDirectoryExists($temporaryDir);
     // START: from FileDownloader::download()
     if (!$package->getDistUrl()) {
         throw new \InvalidArgumentException('The given package is missing url information');
     }
     $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
     $urls = $package->getDistUrls();
     while ($url = array_shift($urls)) {
         try {
             $fileName = $this->doDownload($package, $temporaryDir, $url);
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->writeError('');
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getCode() . ': ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('');
                 $this->io->writeError('    Failed, trying the next URL (' . $e->getCode() . ': ' . $e->getMessage() . ')');
             }
             if (!count($urls)) {
                 throw $e;
             }
         }
     }
     // END: from FileDownloader::download()
     if ($this->io->isVerbose()) {
         $this->io->writeError('    Extracting archive');
     }
     try {
         $this->extract($fileName, $path);
     } catch (\Exception $e) {
         // remove cache if the file was corrupted
         parent::clearCache($package, $path);
         throw $e;
     }
     $this->filesystem->unlink($fileName);
     if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir') . '/composer/')) {
         $this->filesystem->removeDirectory($this->config->get('vendor-dir') . '/composer/');
     }
     if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir'))) {
         $this->filesystem->removeDirectory($this->config->get('vendor-dir'));
     }
     $this->io->writeError('');
 }
開發者ID:tam-bourine,項目名稱:heroku-buildpack-php,代碼行數:46,代碼來源:Downloader.php

示例3: configurePackageTransportOptions

 protected function configurePackageTransportOptions(PackageInterface $package)
 {
     foreach ($package->getDistUrls() as $url) {
         if (strpos($url, $this->baseUrl) === 0) {
             $package->setTransportOptions($this->options);
             return;
         }
     }
 }
開發者ID:aminembarki,項目名稱:composer,代碼行數:9,代碼來源:ComposerRepository.php

示例4: getUrlFromPackage

 private static function getUrlFromPackage(Package\PackageInterface $package)
 {
     $url = $package->getDistUrl();
     if (!$url) {
         return false;
     }
     if ($package->getDistMirrors()) {
         $url = current($package->getDistUrls());
     }
     if (!parse_url($url, PHP_URL_HOST)) {
         return false;
     }
     return $url;
 }
開發者ID:hirak,項目名稱:prestissimo,代碼行數:14,代碼來源:Prefetcher.php

示例5: getDistUrls

 /**
  * {@inheritdoc}
  */
 public function getDistUrls()
 {
     return $this->package->getDistUrls();
 }
開發者ID:tenside,項目名稱:core,代碼行數:7,代碼來源:VersionedPackage.php

示例6: getDistUrls

 public function getDistUrls()
 {
     return $this->aliasOf->getDistUrls();
 }
開發者ID:neon64,項目名稱:composer,代碼行數:4,代碼來源:AliasPackage.php


注:本文中的Composer\Package\PackageInterface::getDistUrls方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。