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


PHP Composer::getRepositoryManager方法代碼示例

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


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

示例1: onPostUpdate

 public function onPostUpdate(Event $event)
 {
     $requires = [];
     $overrides = [];
     $resolutions = [];
     if ($event->isDevMode()) {
         $extra = $this->composer->getPackage()->getExtra();
         $bower = isset($extra['bower']) ? $extra['bower'] : [];
         if (isset($bower['require-dev'])) {
             $requires = $this->_mergeDependencyVersions($requires, $bower['require-dev']);
         }
     }
     $packages = [$this->composer->getPackage()];
     $packages = array_merge($packages, $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages());
     foreach ($packages as $package) {
         if ($package instanceof CompletePackage) {
             $extra = $package->getExtra();
             $bower = isset($extra['bower']) ? $extra['bower'] : [];
             if (isset($bower['require'])) {
                 $requires = $this->_mergeDependencyVersions($requires, $bower['require']);
             }
             if (isset($bower['overrides'])) {
                 $overrides = array_merge_recursive($overrides, $bower['overrides']);
             }
             if (isset($bower['resolutions'])) {
                 $resolutions = $bower['resolutions'];
             }
         }
     }
     if (!$requires) {
         $this->info("No Bower packages are required by the application or by any installed Composer package");
     }
     $dependencies = $this->_installBower($requires, $overrides, $resolutions);
     $this->info((count($dependencies) ?: "No") . " bower packages are installed");
 }
開發者ID:php-kit,項目名稱:composer-bower-plugin,代碼行數:35,代碼來源:Plugin.php

示例2: registerStudioPackages

 /**
  * Register all managed paths with Composer.
  *
  * This function configures Composer to treat all Studio-managed paths as local path repositories, so that packages
  * therein will be symlinked directly.
  */
 public function registerStudioPackages()
 {
     $repoManager = $this->composer->getRepositoryManager();
     $composerConfig = $this->composer->getConfig();
     foreach ($this->getManagedPaths() as $path) {
         $this->io->writeError("[Studio] Loading path {$path}");
         $repoManager->prependRepository(new PathRepository(['url' => $path], $this->io, $composerConfig));
     }
 }
開發者ID:franzliedke,項目名稱:studio,代碼行數:15,代碼來源:StudioPlugin.php

示例3: registerLoader

 private function registerLoader()
 {
     $package = $this->composer->getPackage();
     $generator = $this->composer->getAutoloadGenerator();
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
     $map = $generator->parseAutoloads($packageMap, $package);
     $this->loader = $generator->createLoader($map);
     $this->loader->register();
 }
開發者ID:helhum,項目名稱:typo3-console-plugin,代碼行數:10,代碼來源:ScriptDispatcher.php

示例4: onPostInstallUpdateCmd

 /**
  * Function to run after a package has been updated
  *
  * @param CommandEvent $event
  */
 public function onPostInstallUpdateCmd(CommandEvent $event)
 {
     /** @var \Composer\Repository\WritableRepositoryInterface $repository */
     $repository = $this->composer->getRepositoryManager()->getLocalRepository();
     /** @var \Composer\Package\CompletePackage $package */
     foreach ($repository->getPackages() as $package) {
         if ($package instanceof BasePackage) {
             $this->cleanPackage($package);
         }
     }
 }
開發者ID:barryvdh,項目名稱:composer-cleanup-plugin,代碼行數:16,代碼來源:CleanupPlugin.php

示例5: onPostUpdate

 public function onPostUpdate(Event $event)
 {
     // Load global plugin configuration
     $globalCfg = $this->getGlobalConfig();
     if ($globalCfg) {
         $extra = self::get($globalCfg, 'extra', []);
         $myConfig = self::get($extra, self::EXTRA_KEY, []);
         if ($myConfig) {
             $this->info("Global configuration loaded");
         }
     } else {
         $myConfig = [];
     }
     // Merge project-specific configuration.
     // Ignore it if Composer is running in global mode.
     $package = $this->composer->getPackage();
     if ($package->getName() != '__root__') {
         $projCfg = self::get($package->getExtra(), self::EXTRA_KEY, []);
         $myConfig = array_merge_recursive($myConfig, $projCfg);
         $this->info("Project-specific configuration loaded");
     }
     // Setup
     $rules = array_unique(self::get($myConfig, self::RULES_KEY, []));
     $sharedDir = str_replace('~', getenv('HOME'), self::get($myConfig, self::SHARED_DIR_KEY, self::DEFAULT_SHARED_DIR));
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $rulesInfo = implode(', ', $rules);
     $this->info("Shared directory: <info>{$sharedDir}</info>");
     $this->info("Match packages: <info>{$rulesInfo}</info>");
     $fsUtil = new FilesystemUtil();
     $fs = new Filesystem();
     // Do useful work
     $count = 0;
     foreach ($packages as $package) {
         $srcDir = $this->getInstallPath($package);
         $packageName = $package->getName();
         if (self::globMatchAny($rules, $packageName) && !$fsUtil->isSymlinkedDirectory($srcDir)) {
             $destPath = "{$sharedDir}/{$packageName}";
             if (!file_exists($destPath)) {
                 $fsUtil->copyThenRemove($srcDir, $destPath);
                 $this->info("Moved <info>{$packageName}</info> to shared directory and symlinked to it");
             } else {
                 $fs->remove($srcDir);
                 $this->info("Symlinked to existing <info>{$packageName}</info> on shared directory");
             }
             $fs->symlink($destPath, $srcDir);
             ++$count;
         }
     }
     if (!$count) {
         $this->info("No packages matched");
     }
 }
開發者ID:php-kit,項目名稱:composer-shared-packages-plugin,代碼行數:52,代碼來源:Plugin.php

示例6: dumpAutoloads

 /**
  * @param bool $optimize
  * @param bool $reload
  */
 protected function dumpAutoloads($optimize = true, $reload = false)
 {
     if ($reload) {
         $this->composer = Factory::create($this->io, null, $this->disablePluginsByDefault);
     }
     $config = $this->composer->getConfig();
     $generator = $this->composer->getAutoloadGenerator();
     $installationManager = $this->composer->getInstallationManager();
     $localRepository = $this->composer->getRepositoryManager()->getLocalRepository();
     $package = $this->composer->getPackage();
     $generator->dump($config, $localRepository, $package, $installationManager, 'composer', $optimize);
     $this->info('Composer DumpAutoloads Completed!');
 }
開發者ID:notadd,項目名稱:framework,代碼行數:17,代碼來源:Command.php

示例7: __construct

 /**
  * @param string $baseDir Root directory of composer package.
  */
 public function __construct($baseDir)
 {
     $this->baseDir = $baseDir;
     $io = new NullIO();
     $this->composer = (new Factory())->createComposer($io, $baseDir . '/composer.json', true, $baseDir, false);
     $generator = new AutoloadGenerator($this->composer->getEventDispatcher(), $io);
     $generator->setDevMode(true);
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
     $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $this->composer->getPackage(), $packages);
     $packageMap[0][1] = $baseDir;
     // To make root package paths absolute too.
     $autoloads = $generator->parseAutoloads($packageMap, $this->composer->getPackage());
     $this->classLoader = $generator->createLoader($autoloads);
 }
開發者ID:tsufeki,項目名稱:phpcmplr,代碼行數:17,代碼來源:ComposerPackage.php

示例8: getDependentPackages

 /**
  * Get an array of packages that depend on the target package
  *
  * @param bool $isDevMode
  * @return PackageWrapper[]
  */
 public function getDependentPackages($isDevMode)
 {
     $packages = [];
     $rootPackage = $this->composer->getPackage();
     if ($this->isDependentPackage($rootPackage, (bool) $isDevMode)) {
         $packages[] = new PackageWrapper($rootPackage, getcwd());
     }
     $manager = $this->composer->getInstallationManager();
     foreach ($this->composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
         if ($this->isDependentPackage($package, $isDevMode)) {
             $packages[] = new PackageWrapper($package, $manager->getInstallPath($package));
         }
     }
     return $packages;
 }
開發者ID:budgeit,項目名稱:composer-builder,代碼行數:21,代碼來源:Finder.php

示例9: callRecursive

 /**
  * Call extra recursive
  * @param Composer $composer
  * @param IExtra $extra
  */
 private function callRecursive(Composer $composer, IExtra $extra)
 {
     $extra->run($composer->getPackage(), true);
     foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
         $extra->run($package, false);
     }
 }
開發者ID:pipaslot,項目名稱:modules,代碼行數:12,代碼來源:Extra.php

示例10: dumpFiles

 /**
  * @param \Composer\Composer
  * @param string
  * @param string
  */
 public function dumpFiles(Composer $composer, $paths, $targetDir = 'composer')
 {
     $installationManager = $composer->getInstallationManager();
     $localRepo = $composer->getRepositoryManager()->getLocalRepository();
     $mainPackage = $composer->getPackage();
     $config = $composer->getConfig();
     $filesystem = new Filesystem();
     $basePath = $filesystem->normalizePath(realpath(getcwd()));
     $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
     $targetDir = $vendorPath . '/' . $targetDir;
     $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
     $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
     $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
     $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
     $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
     $autoloads = $this->parseAutoloads($packageMap, $mainPackage);
     $paths = $this->parseAutoloadsTypeFiles($paths, $mainPackage);
     $autoloads['files'] = array_merge($paths, $autoloads['files']);
     $includeFilesFilePath = $targetDir . '/autoload_files.php';
     if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
         file_put_contents($includeFilesFilePath, $includeFilesFileContents);
     } elseif (file_exists($includeFilesFilePath)) {
         unlink($includeFilesFilePath);
     }
 }
開發者ID:funkjedi,項目名稱:composer-include-files,代碼行數:30,代碼來源:AutoloadGenerator.php

示例11: getReferences

 /**
  * finds a list of packages which depend on another package
  *
  * @param  InputInterface            $input
  * @param  OutputInterface           $output
  * @param  Composer                  $composer
  * @return array
  * @throws \InvalidArgumentException
  */
 private function getReferences(InputInterface $input, OutputInterface $output, Composer $composer)
 {
     $needle = $input->getArgument('package');
     $references = array();
     $verbose = (bool) $input->getOption('verbose');
     $repos = $composer->getRepositoryManager()->getRepositories();
     $types = $input->getOption('link-type');
     foreach ($repos as $repository) {
         foreach ($repository->getPackages() as $package) {
             foreach ($types as $type) {
                 $type = rtrim($type, 's');
                 if (!isset($this->linkTypes[$type])) {
                     throw new \InvalidArgumentException('Unexpected link type: ' . $type . ', valid types: ' . implode(', ', array_keys($this->linkTypes)));
                 }
                 foreach ($package->{'get' . $this->linkTypes[$type]}() as $link) {
                     if ($link->getTarget() === $needle) {
                         if ($verbose) {
                             $references[] = array($type, $package, $link);
                         } else {
                             $references[$package->getName()] = $package->getPrettyName();
                         }
                     }
                 }
             }
         }
     }
     return $references;
 }
開發者ID:norbe,項目名稱:composer,代碼行數:37,代碼來源:DependsCommand.php

示例12: getVersion

 /**
  * Returns the PhantomJS version number.
  *
  * Firstly, we search for a version number in the local repository,
  * secondly, in the root package.
  * A version specification of "dev-master#<commit-reference>" is disallowed.
  *
  * @param Composer $composer
  * @return string $version Version
  */
 public static function getVersion($composer)
 {
     $packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
     $os = self::getOS();
     foreach ($packages as $package) {
         if ($package->getName() === 'triplekdev/phantomjs-installer') {
             $version = $package->getPrettyVersion();
         }
     }
     // version was not found in the local repository, let's take a look at the root package
     if ($version == null) {
         $version = self::getRequiredVersion($composer->getPackage(), 'triplekdev/phantomjs-installer');
     }
     // fallback to a hardcoded version number, if "dev-master" was set
     if ($version === 'dev-master') {
         return $os === 'macosx' ? '2.0.1' : '1.9.8';
     }
     // grab version from commit-reference, e.g. "dev-master#<commit-ref> as version"
     if (preg_match('/dev-master#(?:.*)(\\d.\\d.\\d)/i', $version, $matches)) {
         return $matches[1];
     }
     // grab version from a git version tag with a patch level, like "1.9.8-2"
     if (preg_match('/(\\d.\\d.\\d)(?:(?:-\\d)?)/i', $version, $matches)) {
         return $matches[1];
     }
     // grab version from a Composer patch version tag with a patch level, like "1.9.8-p02"
     if (preg_match('/(\\d.\\d.\\d)(?:(?:-p\\d{2})?)/i', $version, $matches)) {
         return $matches[1];
     }
     return $version;
 }
開發者ID:kevmt,項目名稱:phantomjs-installer,代碼行數:41,代碼來源:Installer.php

示例13: getStaticPackages

 /**
  * Get filtered packages array
  */
 public function getStaticPackages() : array
 {
     $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
     return array_filter($packages, function (PackageInterface $package) {
         return $package->getType() == static::PACKAGE_TYPE && $this->getStaticMaps($package->getName());
     });
 }
開發者ID:wearejh,項目名稱:statics-merger,代碼行數:10,代碼來源:StaticsMergerPlugin.php

示例14: activate

 /**
  * @param Composer $composer
  * @param IOInterface $io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $repositoryManager = $composer->getRepositoryManager();
     $extra = $composer->getPackage()->getExtra();
     if (!isset($extra['connect-packages'])) {
         return;
     }
     $versionParser = new VersionParser();
     $links = [];
     foreach ($extra['connect-packages'] as $connectPackage => $version) {
         try {
             $releases = $this->getVersionsForPackage($connectPackage);
         } catch (InvalidArgumentException $e) {
             $message = '<error>Could not find release manifest for module with extension key: "%s". ';
             $message .= 'Did you get the casing right? Error: "%s"</error>';
             $io->writeError(sprintf($message, $connectPackage, $e->getMessage()), true);
             continue;
         } catch (UnexpectedValueException $e) {
             $message = '<error>Non valid XML return from connect for module with extension key: "%s".</error>';
             $message .= $e->getMessage();
             $io->writeError(sprintf($message, $connectPackage), true);
             continue;
         }
         $repository = $this->addPackages($releases, $connectPackage);
         $repositoryManager->addRepository($repository);
         $constraint = $versionParser->parseConstraints($version);
         $links[] = new Link($composer->getPackage()->getName(), $connectPackage, $constraint);
     }
     if (!empty($links)) {
         $requires = $composer->getPackage()->getRequires();
         $requires = array_merge($requires, $links);
         $composer->getPackage()->setRequires($requires);
     }
 }
開發者ID:adam-paterson,項目名稱:magento-connect-composer-plugin,代碼行數:38,代碼來源:Plugin.php

示例15: testSetGetRepositoryManager

 public function testSetGetRepositoryManager()
 {
     $composer = new Composer();
     $manager = $this->getMockBuilder('Composer\\Repository\\RepositoryManager')->disableOriginalConstructor()->getMock();
     $composer->setRepositoryManager($manager);
     $this->assertSame($manager, $composer->getRepositoryManager());
 }
開發者ID:alancleaver,項目名稱:composer,代碼行數:7,代碼來源:ComposerTest.php


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