本文整理汇总了PHP中Composer\Factory::createComposer方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::createComposer方法的具体用法?PHP Factory::createComposer怎么用?PHP Factory::createComposer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Factory
的用法示例。
在下文中一共展示了Factory::createComposer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInjectCoreBundles
/**
* Test that the core bundles get correctly injected.
*
* @return void
*/
public function testInjectCoreBundles()
{
$inOut = $this->getMock('Composer\\IO\\IOInterface');
$factory = new Factory();
$composer = $factory->createComposer($inOut, $this->config);
$plugin = new Plugin();
$local = $composer->getRepositoryManager()->getLocalRepository();
if ($core = $local->findPackages('contao/core')) {
$this->fail('Contao core has already been injected, found version ' . $core[0]->getVersion());
}
$plugin->activate($composer, $inOut);
if (!($core = $local->findPackages('contao/core'))) {
$this->fail('Contao core has not been injected.');
}
$core = $core[0];
$constraint = new Constraint('=', $core->getVersion());
$pool = new Pool('dev');
$pool->addRepository($local);
$this->assertNotNull($core = $pool->whatProvides('contao/core', $constraint));
// bundle names + 'contao-community-alliance/composer-client'
$this->assertCount(8, $core[0]->getRequires());
foreach (array('contao/calendar-bundle', 'contao/comments-bundle', 'contao/core-bundle', 'contao/faq-bundle', 'contao/listing-bundle', 'contao/news-bundle', 'contao/newsletter-bundle') as $bundleName) {
$this->assertNotNull($matches = $pool->whatProvides($bundleName, $constraint));
$this->assertCount(1, $matches);
$this->assertEquals('metapackage', $matches[0]->getType());
}
}
示例2: preUpdate
/**
* Merge repositories and requirements from a separate composer-local.json.
*
* This allows static development dependencies to be shipped with Vanilla, but can be customized with a
* composer-local.json file that specifies additional dependencies such as plugins or compatibility libraries.
*
* @param Event $event The event being fired.
*/
public static function preUpdate(Event $event)
{
self::clearAddonManagerCache();
// Check for a composer-local.json.
$composerLocalPath = './composer-local.json';
if (!file_exists($composerLocalPath)) {
return;
}
$composer = $event->getComposer();
$factory = new Factory();
$localComposer = $factory->createComposer($event->getIO(), $composerLocalPath, true, null, false);
// Merge repositories.
$localRepositories = $localComposer->getRepositoryManager()->getRepositories();
foreach ($localRepositories as $repository) {
/* @var \Composer\Repository\RepositoryInterface $repository */
if (method_exists($repository, 'getRepoConfig')) {
$config = $repository->getRepoConfig();
} else {
$config = ['url' => ''];
}
// Skip the packagist repo.
if (strpos($config['url'], 'packagist.org') !== false) {
continue;
}
$composer->getRepositoryManager()->addRepository($repository);
}
// Merge requirements.
$requires = array_merge($composer->getPackage()->getRequires(), $localComposer->getPackage()->getRequires());
$composer->getPackage()->setRequires($requires);
$devRequires = array_merge($composer->getPackage()->getDevRequires(), $localComposer->getPackage()->getDevRequires());
$composer->getPackage()->setDevRequires($devRequires);
}
示例3: reload
/**
* Reload Composer.
*/
public function reload()
{
// update application components to the latest version
if (file_exists($this->lock_file)) {
unlink($this->lock_file);
}
$this->composer = $this->factory->createComposer($this->getIO());
}
示例4: getComposer
/**
* @return Composer
*/
protected function getComposer()
{
$dir = Module::getRootDir();
$path = $dir . '/composer.json';
\Dotenv::setEnvironmentVariable('COMPOSER', $path);
$factory = new Factory();
return $factory->createComposer(new NullIO(), $path, false, $dir);
}
示例5: getComposer
/**
* @return \Composer\Composer
*/
public static function getComposer()
{
if (!self::$composer) {
$factory = new Factory();
self::$composer = $factory->createComposer(new NullIO(), Yii::getAlias(self::$composerConfigFile), false, Yii::getAlias(self::$composerConfigFilePath));
}
return self::$composer;
}
示例6: testIssue30LoadHousekeeper
/**
* When the plugin is loaded, the event listeners are registered which require the Housekeeper.
*
* When the plugin gets uninstalled the housekeeper does not exist anymore and a "Housekeeper class not found" is
* thrown.
*
* Test for https://github.com/contao-community-alliance/composer-plugin/issues/30
*
* Situation:
* - plugin is installed.
* - plugin get uninstalled.
*
* Result:
* - Housekeeper class not found.
*
* @return void
*/
public function testIssue30LoadHousekeeper()
{
$inOut = $this->getMock('Composer\\IO\\IOInterface');
$factory = new Factory();
$composer = $factory->createComposer($inOut);
$plugin = new Plugin();
$plugin->activate($composer, $inOut);
$this->assertTrue(class_exists('ContaoCommunityAlliance\\Composer\\Plugin\\Housekeeper', false));
}
示例7: whenIRunComposerWithThePlugin
public function whenIRunComposerWithThePlugin()
{
$factory = new Factory();
$this->io = new BufferIO();
$config = array_merge(array('config' => array('vendor-dir' => __DIR__ . '/__tmp/vendor'), 'repositories' => array('packagist' => false)), $this->json);
$composer = $factory->createComposer($this->io, $config, true);
$composer->setLocker(new Locker($this->io, new JsonFile('not-existing'), $composer->getRepositoryManager(), $composer->getInstallationManager(), ''));
$this->executor = new TestProcessExecutorMock();
$composer->getDownloadManager()->setDownloader('git', new GitDownloader($this->io, $composer->getConfig(), $this->executor));
$cache = new Cache($this->io, __DIR__ . '/__tmp/vendor/cache');
$rfs = new TestRemoteFileSystemMock($this->remoteFiles);
$composer->getDownloadManager()->setDownloader('file', new FileDownloader($this->io, $composer->getConfig(), $composer->getEventDispatcher(), $cache, $rfs));
$composer->getPluginManager()->addPlugin(new FidoPlugin(__DIR__ . '/__tmp'));
$update = new UpdateCommand();
$update->setComposer($composer);
$update->setIO($this->io);
$update->run(new ArrayInput(array()), new BufferedOutput());
}
示例8: upgrade
/**
* Upgrade claroline packages.
*/
public function upgrade()
{
$this->removeUpdateLog();
MaintenanceHandler::enableMaintenance();
ini_set('max_execution_time', 1800);
ini_set('memory_limit', '-1');
//get the list of upgradable packages from the cache
$pkgList = $this->getUpgradableFromCache();
$this->updateRequirements('>=', $pkgList);
$ds = DIRECTORY_SEPARATOR;
$factory = new Factory();
$io = new FileIO($this->composerLogFile);
putenv("COMPOSER_HOME={$this->vendorDir}{$ds}composer");
$composer = $factory->createComposer($io, "{$this->vendorDir}{$ds}..{$ds}composer.json", false);
//this is the default github token. An other way to do it must be found sooner or later.
$config = $composer->getConfig();
$config->merge(array('github-oauth' => array('github.com' => '5d86c61eec8089d2dd22aebb79c37bebe4b6f86e')));
$install = Installer::create($io, $composer);
$continue = true;
try {
$install->setDryRun($this->env === 'dev')->setVerbose($this->env === 'dev')->setPreferSource($this->env === 'dev')->setPreferDist($this->env !== 'dev')->setDevMode($this->env === 'dev')->setRunScripts(true)->setOptimizeAutoloader(true)->setUpdate(true);
$install->run();
} catch (\Exception $e) {
file_put_contents($this->composerLogFile, "[Claroline updater Exception]: {$e->getMessage()}\n", FILE_APPEND);
$continue = false;
}
if ($continue) {
try {
$this->updater->run(new ArgvInput(array()), new StreamOutput(fopen($this->composerLogFile, 'a')));
} catch (\Exception $e) {
file_put_contents($this->composerLogFile, "[Claroline updater Exception]: {$e->getMessage()}\n", FILE_APPEND);
$continue = false;
}
if ($continue) {
//remove the old cache file
$this->iniFileManager->remove($this->lastTagsFile);
file_put_contents($this->composerLogFile, "\nDone.", FILE_APPEND);
}
}
}
示例9: createComposer
/**
* Get a composer instance.
*
* @return Composer
*/
public function createComposer()
{
return $this->_factory->createComposer($this->_io, null, false, $this->_root);
}
示例10: createComposer
/**
* Load composer and the composer class loader.
*
* @SuppressWarnings(PHPMD.ShortVariable)
*/
public static function createComposer(IOInterface $io)
{
chdir(COMPOSER_DIR_ABSOULTE);
// try to increase memory limit
static::increaseMemoryLimit();
// register composer class loader
static::registerComposerClassLoader();
// create composer factory
/** @var \Composer\Factory $factory */
$factory = new Factory();
// create composer
if (class_exists('\\Composer\\Util\\Silencer')) {
$composer = Silencer::call(array($factory, 'createComposer'), $io);
} else {
$composer = $factory->createComposer($io);
}
return $composer;
}
示例11: 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;
}
示例12: createComposer
/**
* Load composer and the composer class loader.
*/
static function createComposer(IOInterface $io)
{
chdir(COMPOSER_DIR_ABSOULTE);
// try to increase memory limit
static::increaseMemoryLimit();
// register composer class loader
static::registerComposerClassLoader();
// create composer factory
/** @var \Composer\Factory $factory */
$factory = new Factory();
// create composer
$composer = $factory->createComposer($io);
return $composer;
}
示例13: setUp
/**
* Set up all required helpers and the composer library.
*
* @return void
*/
private function setUp()
{
$this->formatter = $this->application->getHelperSet()->get('formatter');
$this->progress = new ProgressBar($this->output);
$this->progress->setFormat('%current:6d% [%bar%] %elapsed% %message%');
$this->progress->setMessage('');
$this->factory = new Factory();
$this->io = new BufferIO();
$this->composer = $this->factory->createComposer($this->io);
}