コード例 #1
0
ファイル: Installer.php プロジェクト: nicodmf/composer
 /**
  * Run installation (or update)
  */
 public function run()
 {
     if ($this->dryRun) {
         $this->verbose = true;
         $this->runScripts = false;
         $this->installationManager->addInstaller(new NoopInstaller());
     }
     if ($this->preferSource) {
         $this->downloadManager->setPreferSource(true);
     }
     // create installed repo, this contains all local packages + platform packages (php & extensions)
     $installedRootPackage = clone $this->package;
     $installedRootPackage->setRequires(array());
     $installedRootPackage->setDevRequires(array());
     $repos = array_merge($this->repositoryManager->getLocalRepositories(), array(new InstalledArrayRepository(array($installedRootPackage)), new PlatformRepository()));
     $installedRepo = new CompositeRepository($repos);
     if ($this->additionalInstalledRepository) {
         $installedRepo->addRepository($this->additionalInstalledRepository);
     }
     $aliases = $this->aliasPackages();
     if ($this->runScripts) {
         // dispatch pre event
         $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
         $this->eventDispatcher->dispatchCommandEvent($eventName);
     }
     $this->suggestedPackages = array();
     if (!$this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $aliases)) {
         return false;
     }
     if ($this->devMode) {
         if (!$this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $aliases, true)) {
             return false;
         }
     }
     // output suggestions
     foreach ($this->suggestedPackages as $suggestion) {
         if (!$installedRepo->findPackages($suggestion['target'])) {
             $this->io->write($suggestion['source'] . ' suggests installing ' . $suggestion['target'] . ' (' . $suggestion['reason'] . ')');
         }
     }
     if (!$this->dryRun) {
         // write lock
         if ($this->update || !$this->locker->isLocked()) {
             $updatedLock = $this->locker->setLockData($this->repositoryManager->getLocalRepository()->getPackages(), $this->devMode ? $this->repositoryManager->getLocalDevRepository()->getPackages() : null, $aliases, $this->package->getMinimumStability(), $this->package->getStabilityFlags());
             if ($updatedLock) {
                 $this->io->write('<info>Writing lock file</info>');
             }
         }
         // write autoloader
         $this->io->write('<info>Generating autoload files</info>');
         $localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories());
         $this->autoloadGenerator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/composer', true);
         if ($this->runScripts) {
             // dispatch post event
             $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
             $this->eventDispatcher->dispatchCommandEvent($eventName);
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Installer.php プロジェクト: nlegoff/composer
 private function aliasPackages()
 {
     if (!$this->update && $this->locker->isLocked()) {
         $aliases = $this->locker->getAliases();
     } else {
         $aliases = $this->package->getAliases();
     }
     foreach ($aliases as $alias) {
         foreach ($this->repositoryManager->findPackages($alias['package'], $alias['version']) as $package) {
             $package->setAlias($alias['alias_normalized']);
             $package->setPrettyAlias($alias['alias']);
             $package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
         }
         foreach ($this->repositoryManager->getLocalRepositories() as $repo) {
             foreach ($repo->findPackages($alias['package'], $alias['version']) as $package) {
                 $package->setAlias($alias['alias_normalized']);
                 $package->setPrettyAlias($alias['alias']);
                 $package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
                 $package->getRepository()->removePackage($package);
             }
         }
     }
     return $aliases;
 }
コード例 #3
0
ファイル: Factory.php プロジェクト: nicodmf/composer
 protected function purgePackages(Repository\RepositoryManager $rm, Installer\InstallationManager $im)
 {
     foreach ($rm->getLocalRepositories() as $repo) {
         foreach ($repo->getPackages() as $package) {
             if (!$im->isPackageInstalled($repo, $package)) {
                 $repo->removePackage($package);
             }
         }
     }
 }