本文整理汇总了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");
}
示例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));
}
}
示例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();
}
示例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);
}
}
}
示例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");
}
}
示例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!');
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
});
}
示例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);
}
}
示例15: testSetGetRepositoryManager
public function testSetGetRepositoryManager()
{
$composer = new Composer();
$manager = $this->getMockBuilder('Composer\\Repository\\RepositoryManager')->disableOriginalConstructor()->getMock();
$composer->setRepositoryManager($manager);
$this->assertSame($manager, $composer->getRepositoryManager());
}