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


PHP Composer::setInstallationManager方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $loader = new JsonLoader(new ArrayLoader());
     $this->packages = array();
     $this->directory = $this->getUniqueTmpDirectory();
     for ($i = 1; $i <= 7; $i++) {
         $filename = '/Fixtures/plugin-v' . $i . '/composer.json';
         mkdir(dirname($this->directory . $filename), 0777, true);
         $this->packages[] = $loader->load(__DIR__ . $filename);
     }
     $dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
     $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
     $rm = $this->getMockBuilder('Composer\\Repository\\RepositoryManager')->disableOriginalConstructor()->getMock();
     $rm->expects($this->any())->method('getLocalRepository')->will($this->returnValue($this->repository));
     $im = $this->getMock('Composer\\Installer\\InstallationManager');
     $im->expects($this->any())->method('getInstallPath')->will($this->returnCallback(function ($package) {
         return __DIR__ . '/Fixtures/' . $package->getPrettyName();
     }));
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
     $dispatcher = $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
     $this->autoloadGenerator = new AutoloadGenerator($dispatcher);
     $this->composer = new Composer();
     $config = new Config();
     $this->composer->setConfig($config);
     $this->composer->setDownloadManager($dm);
     $this->composer->setRepositoryManager($rm);
     $this->composer->setInstallationManager($im);
     $this->composer->setAutoloadGenerator($this->autoloadGenerator);
     $this->pm = new PluginManager($this->io, $this->composer);
     $this->composer->setPluginManager($this->pm);
     $config->merge(array('config' => array('vendor-dir' => $this->directory . '/Fixtures/', 'home' => $this->directory . '/Fixtures', 'bin-dir' => $this->directory . '/Fixtures/bin')));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:PluginInstallerTest.php

示例2: setUp

 protected function setUp()
 {
     $this->composer = new Composer();
     $this->config = new Config();
     $this->composer->setConfig($this->config);
     $this->composer->setInstallationManager(new InstallationManager());
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
 }
开发者ID:bernardosilva,项目名称:git-hooks-installer-plugin,代码行数:8,代码来源:PluginTest.php

示例3: setUp

 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->composer = new Composer();
     $config = new Config();
     $this->composer->setConfig($config);
     /** @var RootPackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */
     $package = $this->getMock('Composer\\Package\\RootPackageInterface');
     $package->expects($this->any())->method('getExtra')->willReturn(array(SharedPackageInstaller::PACKAGE_TYPE => array('vendor-dir' => sys_get_temp_dir() . '/composer-test-vendor-shared')));
     $this->composer->setPackage($package);
     $this->im = $this->getMock('Composer\\Installer\\InstallationManager');
     $this->composer->setInstallationManager($this->im);
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
 }
开发者ID:letudiant,项目名称:composer-shared-package-plugin,代码行数:17,代码来源:SharedPackagePluginTest.php

示例4: setUp

 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->fs = new SymlinkFilesystem();
     $this->composer = new Composer();
     $composerConfig = new Config();
     $this->composer->setConfig($composerConfig);
     $this->im = $this->getMock('Composer\\Installer\\InstallationManager');
     $this->composer->setInstallationManager($this->im);
     $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor';
     $this->ensureDirectoryExistsAndClear($this->vendorDir);
     $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin';
     $this->ensureDirectoryExistsAndClear($this->binDir);
     $this->dependenciesDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-dependencies';
     $this->ensureDirectoryExistsAndClear($this->dependenciesDir);
     $this->symlinkDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor-shared';
     $composerConfig->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir)));
     $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
     $this->composer->setDownloadManager($this->dm);
     $extraConfig = array(SharedPackageInstaller::PACKAGE_TYPE => array('vendor-dir' => $this->dependenciesDir, 'symlink-dir' => $this->symlinkDir));
     /** @var RootPackage|\PHPUnit_Framework_MockObject_MockObject $package */
     $package = $this->getMock('Composer\\Package\\RootPackageInterface');
     $package->expects($this->any())->method('getExtra')->willReturn($extraConfig);
     $this->composer->setPackage($package);
     $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
     $this->dataManager = $this->getMockBuilder('LEtudiant\\Composer\\Data\\Package\\SharedPackageDataManager')->disableOriginalConstructor()->getMock();
     $vendorDirParams = explode(DIRECTORY_SEPARATOR, $this->vendorDir);
     $this->config = new SharedPackageInstallerConfig(end($vendorDirParams), $this->vendorDir, $extraConfig);
 }
开发者ID:letudiant,项目名称:composer-shared-package-plugin,代码行数:33,代码来源:SharedPackageInstallerTest.php

示例5: testSetGetInstallationManager

 public function testSetGetInstallationManager()
 {
     $composer = new Composer();
     $manager = $this->getMock('Composer\\Installer\\InstallationManager');
     $composer->setInstallationManager($manager);
     $this->assertSame($manager, $composer->getInstallationManager());
 }
开发者ID:alancleaver,项目名称:composer,代码行数:7,代码来源:ComposerTest.php

示例6: setUp

 protected function setUp()
 {
     $this->tempDir = TestUtil::makeTempDir('puli-composer-plugin', __CLASS__);
     $filesystem = new Filesystem();
     $filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
     $this->config = new Config(false, $this->tempDir);
     $this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
     $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
     $this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
     $this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
     $this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1'), 'vendor/package2' => new Link('vendor/root', 'vendor/package2')));
     $this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
     $this->repositoryManager = new RepositoryManager($this->io, $this->config);
     $this->repositoryManager->setLocalRepository($this->localRepository);
     $this->installPaths = array();
     $this->composer = new Composer();
     $this->composer->setRepositoryManager($this->repositoryManager);
     $this->composer->setInstallationManager($this->installationManager);
     $this->composer->setConfig($this->config);
     $this->composer->setPackage($this->rootPackage);
     $this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
     $this->previousWd = getcwd();
     chdir($this->tempDir);
     $this->plugin = new PuliPlugin($this->puliRunner);
 }
开发者ID:kormik,项目名称:composer-plugin,代码行数:26,代码来源:PuliPluginTest.php

示例7: setUp

 protected function setUp()
 {
     while (false === mkdir($this->tempDir = sys_get_temp_dir() . '/puli-plugin/PuliPluginTest_root' . rand(10000, 99999), 0777, true)) {
     }
     $filesystem = new Filesystem();
     $filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
     $this->config = new Config(false, $this->tempDir);
     $this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
     $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
     $this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
     $this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
     $this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
     $this->repositoryManager = new RepositoryManager($this->io, $this->config);
     $this->repositoryManager->setLocalRepository($this->localRepository);
     $this->installPaths = array();
     $this->composer = new Composer();
     $this->composer->setRepositoryManager($this->repositoryManager);
     $this->composer->setInstallationManager($this->installationManager);
     $this->composer->setConfig($this->config);
     $this->composer->setPackage($this->rootPackage);
     $this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
     $this->previousWd = getcwd();
     chdir($this->tempDir);
     $this->plugin = new PuliPlugin($this->puliRunner);
 }
开发者ID:niklongstone,项目名称:composer-plugin,代码行数:26,代码来源:PuliPluginTest.php

示例8: setUp

 /**
  * Setup.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor';
     $this->ensureDirectoryExistsAndClear($this->vendorDir);
     $this->composer = new \Composer\Composer();
     $config = new \Composer\Config();
     $this->composer->setConfig($config);
     /** @var \Composer\Package\RootPackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */
     $package = $this->getMock('Composer\\Package\\RootPackageInterface');
     $package->expects($this->any())->method('getExtra')->willReturn(array(PhpCodesnifferStandardInstaller::PACKAGE_TYPE => array('vendor-dir' => $this->vendorDir)));
     $config->merge(array('config' => array('vendor-dir' => $this->vendorDir)));
     $this->composer->setPackage($package);
     $this->im = $this->getMock('Composer\\Installer\\InstallationManager');
     $this->composer->setInstallationManager($this->im);
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
 }
开发者ID:sseidelmann,项目名称:CodesnifferInstaller,代码行数:20,代码来源:PhpCodesnifferStandardInstallerTest.php

示例9: setUp

 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     $this->file = new Filesystem();
     $this->composer = new Composer();
     $this->config = new Config();
     $this->composer->setConfig($this->config);
     $this->composer->setInstallationManager(new InstallationManager());
     $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor';
     $this->ensureDirectoryExistsAndClear($this->vendorDir);
     $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin';
     $this->ensureDirectoryExistsAndClear($this->binDir);
     $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir)));
     $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
     $this->composer->setDownloadManager($this->dm);
     $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
     $this->io = $this->getMock('Composer\\IO\\IOInterface');
 }
开发者ID:lappuse,项目名称:composer-installer,代码行数:22,代码来源:TestCase.php

示例10: setUp

 public function setUp()
 {
     $this->filesystem = new Filesystem();
     $this->composer = new Composer();
     $this->config = new Config();
     $this->io = new NullIO();
     $this->componentDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-componentDir';
     $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-vendorDir';
     $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-binDir';
     foreach (array($this->componentDir, $this->vendorDir, $this->binDir) as $dir) {
         if (is_dir($dir)) {
             $this->filesystem->removeDirectory($dir);
         }
         $this->filesystem->ensureDirectoryExists($dir);
     }
     $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'component-dir' => $this->componentDir, 'bin-dir' => $this->binDir)));
     $this->composer->setConfig($this->config);
     // Set up the Installation Manager.
     $this->installationManager = new InstallationManager();
     $this->installationManager->addInstaller(new LibraryInstaller($this->io, $this->composer));
     $this->installationManager->addInstaller(new Installer($this->io, $this->composer));
     $this->composer->setInstallationManager($this->installationManager);
 }
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:23,代码来源:ProcessTest.php

示例11: activate

 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->repo = new LocalRepository($composer->getConfig());
     // root package
     $root = $composer->getPackage();
     // adding requires from dependent local packages onto the root package
     $rootName = basename($root->getPrettyName());
     // merge in require from local packages
     $packages = array_keys($root->getRequires());
     $requires = $this->getLinks($packages, $rootName);
     $root->setRequires(array_merge($requires, $root->getRequires()));
     // merge in require-dev from local packages
     $packages = array_keys($root->getDevRequires());
     $requires = $this->getLinks($packages, $rootName);
     $root->setDevRequires(array_merge($requires, $root->getDevRequires()));
     $this->installer = new LocalInstaller($composer, $io, $this->repo);
     $this->installer->setInstallManager($composer->getInstallationManager());
     // 		$composer->getInstallationManager()->addInstaller($this->installer);
     $this->installManager = new InstallationManager();
     $this->installManager->addInstaller($this->installer);
     $composer->setInstallationManager($this->installManager);
     // 		// install scripts to hook into composer
     // 		$root = $composer->getPackage();
     // 		$scripts = $root->getScripts();
     // 		$preInstall = isset($scripts['pre-install-cmd']) ? $scripts['pre-install-cmd'] : array();
     // 		$preUpdate = isset($scripts['pre-update-cmd']) ? $scripts['pre-update-cmd'] : array();
     // 		$prePackageInstall = isset($scripts['pre-package-install']) ? $scripts['pre-package-install'] : array();
     // 		$prePackageUpdate = isset($scripts['pre-package-update']) ? $scripts['pre-package-update'] : array();
     // 		$preDependencySolving = isset($scripts['pre-dependencies-solving']) ? $scripts['pre-dependencies-solving'] : array();
     // 		$preInstall[] = 'gossi\\composer\\localdev\\ComposerLocaldevPlugin::preInstall';
     // 		$preUpdate[] = 'gossi\\composer\\localdev\\ComposerLocaldevPlugin::preInstall';
     // 		$prePackageInstall[] = 'gossi\\composer\\localdev\\ComposerLocaldevPlugin::prePackageInstall';
     // 		$prePackageUpdate[] = 'gossi\\composer\\localdev\\ComposerLocaldevPlugin::prePackageUpdate';
     // 		$preDependencySolving[] = 'gossi\\composer\\localdev\\ComposerLocaldevPlugin::preDependencySolving';
     // 		$scripts['pre-install-cmd'] = $preInstall;
     // 		$scripts['pre-update-cmd'] = $preUpdate;
     // 		$scripts['pre-package-install'] = $prePackageInstall;
     // 		$scripts['pre-package-update'] = $prePackageUpdate;
     // 		$scripts['pre-dependencies-solving'] = $preDependencySolving;
     // 		$root->setScripts($scripts);
     self::$instance = $this;
 }
开发者ID:gossi,项目名称:composer-localdev-plugin,代码行数:43,代码来源:ComposerLocaldevPlugin.php

示例12: updateDevelopmentToStable

 /**
  * @test
  *
  * @depends testInstallerCreationShouldNotCreateVendorDirectory
  * @depends testInstallerCreationShouldNotCreateBinDirectory
  */
 public function updateDevelopmentToStable()
 {
     $initial = $this->createDevelopmentPackageMock();
     $target = $this->createStablePackageMock();
     $installer = new SharedPackageInstaller($this->io, $this->composer, $this->fs, $this->dataManager);
     $defaultInstaller = $this->getMockBuilder('Composer\\Installer\\LibraryInstaller')->disableOriginalConstructor()->getMock();
     $defaultInstaller->expects($this->once())->method('install');
     $im = new InstallationManager();
     $im->addInstaller(new SharedPackageInstallerSolver($installer, $defaultInstaller));
     $this->composer->setInstallationManager($im);
     $initial->expects($this->any())->method('getPrettyName')->will($this->returnValue('initial-package'));
     $initial->expects($this->once())->method('getType')->willReturn('shared-package');
     $target->expects($this->once())->method('getType')->willReturn('shared-package');
     $target->expects($this->any())->method('getPrettyName')->will($this->returnValue('package1'));
     $target->expects($this->any())->method('getTargetDir')->will($this->returnValue('newtarget'));
     $this->repository->expects($this->exactly(1))->method('hasPackage')->will($this->onConsecutiveCalls(true, true, false, false));
     $installer->update($this->repository, $initial, $target);
     $this->assertFileExists($this->vendorDir, 'Vendor dir should be created');
     $this->assertFileExists($this->binDir, 'Bin dir should be created');
     $this->assertFileExists($this->dependenciesDir, 'Dependencies dir should be created');
     $this->assertFileNotExists($this->symlinkDir, 'Symlink dir should be created');
     $this->assertFalse(is_link($this->symlinkDir . '/letudiant/foo-bar'));
 }
开发者ID:JasLin,项目名称:composer-shared-package-plugin,代码行数:29,代码来源:SharedPackageInstallerTest.php

示例13: createComposer

 /**
  * Creates a Composer instance
  *
  * @param  IOInterface               $io             IO instance
  * @param  array|string|null         $localConfig    either a configuration array or a filename to read from, if null it will
  *                                                   read from the default filename
  * @param  bool                      $disablePlugins Whether plugins should not be loaded
  * @param  bool                      $fullLoad       Whether to initialize everything or only main project stuff (used when loading the global composer)
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
 {
     $cwd = $cwd ?: getcwd();
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = static::getComposerFile();
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, null, $io);
         if (!$file->exists()) {
             if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
                 $message = 'Composer could not find a composer.json file in ' . $cwd;
             } else {
                 $message = 'Composer could not find the config file: ' . $localConfig;
             }
             $instructions = 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section';
             throw new \InvalidArgumentException($message . PHP_EOL . $instructions);
         }
         $file->validateSchema(JsonFile::LAX_SCHEMA);
         $jsonParser = new JsonParser();
         try {
             $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
         } catch (\Seld\JsonLint\DuplicateKeyException $e) {
             $details = $e->getDetails();
             $io->writeError('<warning>Key ' . $details['key'] . ' is a duplicate in ' . $localConfig . ' at line ' . $details['line'] . '</warning>');
         }
         $localConfig = $file->read();
     }
     // Load config and override with local config/auth config
     $config = static::createConfig($io, $cwd);
     $config->merge($localConfig);
     if (isset($composerFile)) {
         $io->writeError('Loading config file ' . $composerFile, true, IOInterface::DEBUG);
         $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
         if ($localAuthFile->exists()) {
             $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
             $config->merge(array('config' => $localAuthFile->read()));
             $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
         }
     }
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     if ($fullLoad) {
         // load auth configs into the IO instance
         $io->loadConfiguration($config);
     }
     $rfs = self::createRemoteFilesystem($io, $config);
     // initialize event dispatcher
     $dispatcher = new EventDispatcher($composer, $io);
     $composer->setEventDispatcher($dispatcher);
     // initialize repository manager
     $rm = $this->createRepositoryManager($io, $config, $dispatcher, $rfs);
     $composer->setRepositoryManager($rm);
     // load local repository
     $this->addLocalRepository($io, $rm, $vendorDir);
     // force-set the version of the global package if not defined as
     // guessing it adds no value and only takes time
     if (!$fullLoad && !isset($localConfig['version'])) {
         $localConfig['version'] = '1.0.0';
     }
     // load package
     $parser = new VersionParser();
     $guesser = new VersionGuesser($config, new ProcessExecutor($io), $parser);
     $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser);
     $package = $loader->load($localConfig, 'Composer\\Package\\RootPackage', $cwd);
     $composer->setPackage($package);
     // initialize installation manager
     $im = $this->createInstallationManager();
     $composer->setInstallationManager($im);
     if ($fullLoad) {
         // initialize download manager
         $dm = $this->createDownloadManager($io, $config, $dispatcher, $rfs);
         $composer->setDownloadManager($dm);
         // initialize autoload generator
         $generator = new AutoloadGenerator($dispatcher, $io);
         $composer->setAutoloadGenerator($generator);
     }
     // add installers to the manager (must happen after download manager is created since they read it out of $composer)
     $this->createDefaultInstallers($im, $composer, $io);
     if ($fullLoad) {
         $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
         $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
         $composer->setPluginManager($pm);
         $pm->loadInstalledPlugins();
//.........这里部分代码省略.........
开发者ID:tommygoud,项目名称:composer,代码行数:101,代码来源:Factory.php

示例14: createComposer

 /**
  * Creates a Composer instance
  *
  * @param IOInterface       $io          IO instance
  * @param array|string|null $localConfig either a configuration array or a filename to read from, if null it will
  *                                       read from the default filename
  * @throws \InvalidArgumentException
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null)
 {
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = static::getComposerFile();
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, new RemoteFilesystem($io));
         if (!$file->exists()) {
             if ($localConfig === 'composer.json') {
                 $message = 'Composer could not find a composer.json file in ' . getcwd();
             } else {
                 $message = 'Composer could not find the config file: ' . $localConfig;
             }
             $instructions = 'To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section';
             throw new \InvalidArgumentException($message . PHP_EOL . $instructions);
         }
         $file->validateSchema(JsonFile::LAX_SCHEMA);
         $localConfig = $file->read();
     }
     // Configuration defaults
     $config = static::createConfig();
     $config->merge($localConfig);
     // reload oauth token from config if available
     if ($tokens = $config->get('github-oauth')) {
         foreach ($tokens as $domain => $token) {
             if (!preg_match('{^[a-z0-9]+$}', $token)) {
                 throw new \UnexpectedValueException('Your github oauth token for ' . $domain . ' contains invalid characters: "' . $token . '"');
             }
             $io->setAuthentication($domain, $token, 'x-oauth-basic');
         }
     }
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
     // initialize repository manager
     $rm = $this->createRepositoryManager($io, $config);
     // load local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $loader = new Package\Loader\RootPackageLoader($rm, $config);
     $package = $loader->load($localConfig);
     // initialize download manager
     $dm = $this->createDownloadManager($io, $config);
     // initialize installation manager
     $im = $this->createInstallationManager();
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setDownloadManager($dm);
     $composer->setInstallationManager($im);
     // initialize event dispatcher
     $dispatcher = new EventDispatcher($composer, $io);
     $composer->setEventDispatcher($dispatcher);
     // initialize autoload generator
     $generator = new AutoloadGenerator($dispatcher);
     $composer->setAutoloadGenerator($generator);
     // add installers to the manager
     $this->createDefaultInstallers($im, $composer, $io);
     // purge packages if they have been deleted on the filesystem
     $this->purgePackages($rm, $im);
     // init locker if possible
     if (isset($composerFile)) {
         $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
         $locker = new Package\Locker(new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, $im, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:82,代码来源:Factory.php

示例15: createComposer

 /**
  * Creates a Composer instance
  *
  * @param  IOInterface               $io             IO instance
  * @param  array|string|null         $localConfig    either a configuration array or a filename to read from, if null it will
  *                                                   read from the default filename
  * @param  bool                      $disablePlugins Whether plugins should not be loaded
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false)
 {
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = static::getComposerFile();
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, new RemoteFilesystem($io));
         if (!$file->exists()) {
             if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
                 $message = 'Composer could not find a composer.json file in ' . getcwd();
             } else {
                 $message = 'Composer could not find the config file: ' . $localConfig;
             }
             $instructions = 'To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section';
             throw new \InvalidArgumentException($message . PHP_EOL . $instructions);
         }
         $file->validateSchema(JsonFile::LAX_SCHEMA);
         $localConfig = $file->read();
     }
     // Load config and override with local config/auth config
     $config = static::createConfig($io);
     $config->merge($localConfig);
     if (isset($composerFile)) {
         if ($io && $io->isDebug()) {
             $io->write('Loading config file ' . $composerFile);
         }
         $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
         if ($localAuthFile->exists()) {
             if ($io && $io->isDebug()) {
                 $io->write('Loading config file ' . $localAuthFile->getPath());
             }
             $config->merge(array('config' => $localAuthFile->read()));
             $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
         }
     }
     // load auth configs into the IO instance
     $io->loadConfiguration($config);
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     // initialize event dispatcher
     $dispatcher = new EventDispatcher($composer, $io);
     // initialize repository manager
     $rm = $this->createRepositoryManager($io, $config, $dispatcher);
     // load local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $parser = new VersionParser();
     $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, new ProcessExecutor($io));
     $package = $loader->load($localConfig);
     // initialize installation manager
     $im = $this->createInstallationManager();
     // Composer composition
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setInstallationManager($im);
     // initialize download manager
     $dm = $this->createDownloadManager($io, $config, $dispatcher);
     $composer->setDownloadManager($dm);
     $composer->setEventDispatcher($dispatcher);
     // initialize autoload generator
     $generator = new AutoloadGenerator($dispatcher, $io);
     $composer->setAutoloadGenerator($generator);
     // add installers to the manager
     $this->createDefaultInstallers($im, $composer, $io);
     $globalRepository = $this->createGlobalRepository($config, $vendorDir);
     $pm = $this->createPluginManager($composer, $io, $globalRepository);
     $composer->setPluginManager($pm);
     if (!$disablePlugins) {
         $pm->loadInstalledPlugins();
     }
     // purge packages if they have been deleted on the filesystem
     $this->purgePackages($rm, $im);
     // init locker if possible
     if (isset($composerFile)) {
         $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
         $locker = new Package\Locker($io, new JsonFile($lockFile, new RemoteFilesystem($io, $config)), $rm, $im, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:VSeryi,项目名称:TechnicSolder,代码行数:98,代码来源:Factory.php


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