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


PHP Factory::createDownloadManager方法代码示例

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


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

示例1: dump

 /**
  * Builds the archives of the repository.
  *
  * @param array $packages List of packages to dump
  */
 public function dump(array $packages)
 {
     $helper = new ArchiveBuilderHelper($this->output, $this->config['archive']);
     $directory = $helper->getDirectory($this->outputDir);
     $this->output->writeln(sprintf("<info>Creating local downloads in '%s'</info>", $directory));
     $format = isset($this->config['archive']['format']) ? $this->config['archive']['format'] : 'zip';
     $endpoint = isset($this->config['archive']['prefix-url']) ? $this->config['archive']['prefix-url'] : $this->config['homepage'];
     $includeArchiveChecksum = isset($this->config['archive']['checksum']) ? (bool) $this->config['archive']['checksum'] : true;
     $composerConfig = Factory::createConfig();
     $factory = new Factory();
     $io = new ConsoleIO($this->input, $this->output, $this->helperSet);
     $io->loadConfiguration($composerConfig);
     /* @var \Composer\Downloader\DownloadManager $downloadManager */
     $downloadManager = $factory->createDownloadManager($io, $composerConfig);
     /* @var \Composer\Package\Archiver\ArchiveManager $archiveManager */
     $archiveManager = $factory->createArchiveManager($composerConfig, $downloadManager);
     $archiveManager->setOverwriteFiles(false);
     shuffle($packages);
     /* @var \Composer\Package\CompletePackage $package */
     foreach ($packages as $package) {
         if ($helper->isSkippable($package)) {
             continue;
         }
         $this->output->writeln(sprintf("<info>Dumping '%s'.</info>", $package->getName()));
         try {
             if ('pear-library' === $package->getType()) {
                 // PEAR packages are archives already
                 $filesystem = new Filesystem();
                 $packageName = $archiveManager->getPackageFilename($package);
                 $path = realpath($directory) . '/' . $packageName . '.' . pathinfo($package->getDistUrl(), PATHINFO_EXTENSION);
                 if (!file_exists($path)) {
                     $downloadDir = sys_get_temp_dir() . '/composer_archiver/' . $packageName;
                     $filesystem->ensureDirectoryExists($downloadDir);
                     $downloadManager->download($package, $downloadDir, false);
                     $filesystem->ensureDirectoryExists($directory);
                     $filesystem->rename($downloadDir . '/' . pathinfo($package->getDistUrl(), PATHINFO_BASENAME), $path);
                     $filesystem->removeDirectory($downloadDir);
                 }
                 // Set archive format to `file` to tell composer to download it as is
                 $archiveFormat = 'file';
             } else {
                 $path = $archiveManager->archive($package, $format, $directory);
                 $archiveFormat = $format;
             }
             $archive = basename($path);
             $distUrl = sprintf('%s/%s/%s', $endpoint, $this->config['archive']['directory'], $archive);
             $package->setDistType($archiveFormat);
             $package->setDistUrl($distUrl);
             if ($includeArchiveChecksum) {
                 $package->setDistSha1Checksum(hash_file('sha1', $path));
             }
             $package->setDistReference($package->getSourceReference());
         } catch (\Exception $exception) {
             if (!$this->skipErrors) {
                 throw $exception;
             }
             $this->output->writeln(sprintf("<error>Skipping Exception '%s'.</error>", $exception->getMessage()));
         }
     }
 }
开发者ID:robertgit,项目名称:satis,代码行数:65,代码来源:ArchiveBuilder.php

示例2: getDownloadManager

 private function getDownloadManager()
 {
     if (!$this->downloadManager) {
         $config = Factory::createConfig();
         $factory = new Factory();
         $this->downloadManager = $factory->createDownloadManager($this->getIO(), $config);
     }
     return $this->downloadManager;
 }
开发者ID:stof,项目名称:packanalyst,代码行数:9,代码来源:RunCommand.php

示例3: archive

 protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.')
 {
     $factory = new Factory();
     $downloadManager = $factory->createDownloadManager($io, $config);
     $archiveManager = $factory->createArchiveManager($config, $downloadManager);
     if ($packageName) {
         $package = $this->selectPackage($io, $packageName, $version);
         if (!$package) {
             return 1;
         }
     } else {
         $package = $this->getComposer()->getPackage();
     }
     $io->writeError('<info>Creating the archive into "' . $dest . '".</info>');
     $archiveManager->archive($package, $format, $dest);
     return 0;
 }
开发者ID:arunkumar741,项目名称:composer,代码行数:17,代码来源:ArchiveCommand.php

示例4: archive

 protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null)
 {
     $factory = new Factory();
     $downloadManager = $factory->createDownloadManager($io, $config);
     $archiveManager = $factory->createArchiveManager($config, $downloadManager);
     if ($packageName) {
         $package = $this->selectPackage($io, $packageName, $version);
         if (!$package) {
             return 1;
         }
     } else {
         $package = $this->getComposer()->getPackage();
     }
     $io->writeError('<info>Creating the archive into "' . $dest . '".</info>');
     $packagePath = $archiveManager->archive($package, $format, $dest, $fileName);
     $fs = new Filesystem();
     $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
     $io->writeError('Created: ', false);
     $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
     return 0;
 }
开发者ID:alancleaver,项目名称:composer,代码行数:21,代码来源:ArchiveCommand.php

示例5: createDownloadManager

 protected function createDownloadManager(IOInterface $io, Config $config)
 {
     $factory = new Factory();
     return $factory->createDownloadManager($io, $config);
 }
开发者ID:arunkumar741,项目名称:composer,代码行数:5,代码来源:CreateProjectCommand.php

示例6: dumpDownloads

 /**
  * @param array           $config   Directory where to create the downloads in, prefix-url, etc..
  * @param array           $packages
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param string          $outputDir
  * @param bool            $skipErrors   If true, any exception while dumping a package will be ignored.
  *
  * @return void
  */
 private function dumpDownloads(array $config, array $packages, InputInterface $input, OutputInterface $output, $outputDir, $skipErrors)
 {
     if (isset($config['archive']['absolute-directory'])) {
         $directory = $config['archive']['absolute-directory'];
     } else {
         $directory = sprintf('%s/%s', $outputDir, $config['archive']['directory']);
     }
     $output->writeln(sprintf("<info>Creating local downloads in '%s'</info>", $directory));
     $format = isset($config['archive']['format']) ? $config['archive']['format'] : 'zip';
     $endpoint = isset($config['archive']['prefix-url']) ? $config['archive']['prefix-url'] : $config['homepage'];
     $skipDev = isset($config['archive']['skip-dev']) ? (bool) $config['archive']['skip-dev'] : false;
     $whitelist = isset($config['archive']['whitelist']) ? (array) $config['archive']['whitelist'] : array();
     $blacklist = isset($config['archive']['blacklist']) ? (array) $config['archive']['blacklist'] : array();
     $includeArchiveChecksum = isset($config['archive']['checksum']) ? (bool) $config['archive']['checksum'] : true;
     $composerConfig = Factory::createConfig();
     $factory = new Factory();
     $io = new ConsoleIO($input, $output, $this->getApplication()->getHelperSet());
     $io->loadConfiguration($composerConfig);
     /* @var \Composer\Downloader\DownloadManager $downloadManager */
     $downloadManager = $factory->createDownloadManager($io, $composerConfig);
     /* @var \Composer\Package\Archiver\ArchiveManager $archiveManager */
     $archiveManager = $factory->createArchiveManager($composerConfig, $downloadManager);
     $archiveManager->setOverwriteFiles(false);
     shuffle($packages);
     /* @var \Composer\Package\CompletePackage $package */
     foreach ($packages as $package) {
         if ('metapackage' === $package->getType()) {
             continue;
         }
         $name = $package->getName();
         if (true === $skipDev && true === $package->isDev()) {
             $output->writeln(sprintf("<info>Skipping '%s' (is dev)</info>", $name));
             continue;
         }
         $names = $package->getNames();
         if ($whitelist && !array_intersect($whitelist, $names)) {
             $output->writeln(sprintf("<info>Skipping '%s' (is not in whitelist)</info>", $name));
             continue;
         }
         if ($blacklist && array_intersect($blacklist, $names)) {
             $output->writeln(sprintf("<info>Skipping '%s' (is in blacklist)</info>", $name));
             continue;
         }
         $output->writeln(sprintf("<info>Dumping '%s'.</info>", $name));
         try {
             if ('pear-library' === $package->getType()) {
                 // PEAR packages are archives already
                 $filesystem = new Filesystem();
                 $packageName = $archiveManager->getPackageFilename($package);
                 $path = realpath($directory) . '/' . $packageName . '.' . pathinfo($package->getDistUrl(), PATHINFO_EXTENSION);
                 if (!file_exists($path)) {
                     $downloadDir = sys_get_temp_dir() . '/composer_archiver/' . $packageName;
                     $filesystem->ensureDirectoryExists($downloadDir);
                     $downloadManager->download($package, $downloadDir, false);
                     $filesystem->ensureDirectoryExists($directory);
                     $filesystem->rename($downloadDir . '/' . pathinfo($package->getDistUrl(), PATHINFO_BASENAME), $path);
                     $filesystem->removeDirectory($downloadDir);
                 }
                 // Set archive format to `file` to tell composer to download it as is
                 $archiveFormat = 'file';
             } else {
                 $path = $archiveManager->archive($package, $format, $directory);
                 $archiveFormat = $format;
             }
             $archive = basename($path);
             $distUrl = sprintf('%s/%s/%s', $endpoint, $config['archive']['directory'], $archive);
             $package->setDistType($archiveFormat);
             $package->setDistUrl($distUrl);
             if ($includeArchiveChecksum) {
                 $package->setDistSha1Checksum(hash_file('sha1', $path));
             }
             $package->setDistReference($package->getSourceReference());
         } catch (\Exception $exception) {
             if (!$skipErrors) {
                 throw $exception;
             }
             $output->writeln(sprintf("<error>Skipping Exception '%s'.</error>", $exception->getMessage()));
         }
     }
 }
开发者ID:nfreear,项目名称:satis,代码行数:90,代码来源:BuildCommand.php

示例7: createComposer

 public function createComposer()
 {
     $cwd = sprintf('%s/%s', getcwd(), '.eva');
     $factory = new Factory();
     if (false) {
         $composer = $factory->createComposer($this->io, $config, true, $cwd);
     }
     //  -----------------
     //  -----------------
     //  -----------------
     $fullLoad = true;
     $composerFile = $cwd . '/manifest.composer.json';
     $file = new JsonFile($composerFile);
     $file->validateSchema(JsonFile::LAX_SCHEMA);
     $localConfig = $file->read();
     //  -----------------
     //  -----------------
     //  -----------------
     // Load config and override with local config/auth config
     //        $config = Factory::createConfig($this->io, $cwd);
     $vendorDir = $cwd . '/manifests/vendor';
     $config = $factory::createConfig($this->io, $cwd);
     $config->merge($localConfig);
     $config->merge(['config' => ['vendor-dir' => $vendorDir]]);
     $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
     if ($localAuthFile->exists()) {
         if ($this->io && $this->io->isDebug()) {
             $this->io->writeError('Loading config file ' . $localAuthFile->getPath());
         }
         $config->merge(array('config' => $localAuthFile->read()));
         $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
     }
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     // initialize event dispatcher
     $dispatcher = new EventDispatcher($composer, $this->io);
     $composer->setEventDispatcher($dispatcher);
     // initialize repository manager
     //        $rm = $this->createRepositoryManager($io, $config, $dispatcher);
     //        $composer->setRepositoryManager($rm);
     $rm = new RepositoryManager($this->io, $config, $dispatcher);
     $rm->setRepositoryClass('composer', ComposerRepository::class);
     $composer->setRepositoryManager($rm);
     // load local repository
     $rm->setLocalRepository(new InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json')));
     // load package
     $parser = new VersionParser();
     $guesser = new VersionGuesser($config, new ProcessExecutor($this->io), $parser);
     $loader = new RootPackageLoader($rm, $config, $parser, $guesser);
     $package = $loader->load($localConfig);
     $composer->setPackage($package);
     // initialize installation manager
     $im = new InstallationManager();
     $composer->setInstallationManager($im);
     if ($fullLoad) {
         // initialize download manager
         $dm = $factory->createDownloadManager($this->io, $config, $dispatcher);
         $composer->setDownloadManager($dm);
         // initialize autoload generator
         $generator = new AutoloadGenerator($dispatcher, $this->io);
         $composer->setAutoloadGenerator($generator);
     }
     // add installers to the manager (must happen after download manager is created since they read it out of $composer)
     $im->addInstaller(new Installer\LibraryInstaller($this->io, $composer, null));
     $im->addInstaller(new Installer\PearInstaller($this->io, $composer, 'pear-library'));
     $im->addInstaller(new Installer\PluginInstaller($this->io, $composer));
     $im->addInstaller(new Installer\MetapackageInstaller($this->io));
     //        if ($fullLoad) {
     //            $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
     //            $pm = $this->createPluginManager($io, $composer, $globalComposer);
     //            $composer->setPluginManager($pm);
     //
     //            if (!$disablePlugins) {
     //                $pm->loadInstalledPlugins();
     //            }
     //
     //            // once we have plugins and custom installers we can
     //            // purge packages from local repos if they have been deleted on the filesystem
     //            if ($rm->getLocalRepository()) {
     //                $this->purgePackages($rm->getLocalRepository(), $im);
     //            }
     //        }
     // init locker if possible
     if ($fullLoad && isset($composerFile)) {
         $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
         $locker = new Locker($this->io, new JsonFile($lockFile, new RemoteFilesystem($this->io, $config)), $rm, $im, file_get_contents($composerFile));
         $composer->setLocker($locker);
     }
     //  -----------------
     //  -----------------
     //  -----------------
     return $composer;
 }
开发者ID:eva,项目名称:eva,代码行数:94,代码来源:ComposerFactory.php


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