diff --git a/doc/05-repositories.md b/doc/05-repositories.md index 14b18337e..b8f57e665 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -490,7 +490,7 @@ information. There are some cases, when there is no ability to have one of the previously mentioned repository types online, even the VCS one. Typical example could be cross-organisation library exchange through built artifacts. Of course, most -of the times they are private. To simplify maintenance, one can simply specify +of the times they are private. To simplify maintenance, one can simply use a repository of type `artifact` with a folder containing ZIP archives of those private packages: @@ -514,10 +514,10 @@ Each zip artifact is just a ZIP archive with `composer.json` in root folder: composer.json ... -If there is two archives with different versions of a package, they would be -imported both. If archive with newer version would be put to artifact folder and -`update` command would be triggered, that version would replace previous, at it - logically seems. +If there are two archives with different versions of a package, they are both +imported. When an archive with a newer version is added in the artifact folder +and you run `update`, that version will be imported as well and Composer will +update to the latest version. ## Disabling Packagist diff --git a/src/Composer/Repository/ArtifactRepository.php b/src/Composer/Repository/ArtifactRepository.php index 0175c85f3..7910d62f7 100644 --- a/src/Composer/Repository/ArtifactRepository.php +++ b/src/Composer/Repository/ArtifactRepository.php @@ -28,6 +28,10 @@ class ArtifactRepository extends ArrayRepository public function __construct(array $repoConfig, IOInterface $io) { + if (!extension_loaded('zip')) { + throw new \RuntimeException('The artifact repository requires PHP\'s zip extension'); + } + $this->loader = new ArrayLoader(); $this->lookup = $repoConfig['url']; $this->io = $io; @@ -37,13 +41,6 @@ class ArtifactRepository extends ArrayRepository { parent::initialize(); - if (!extension_loaded('zip')) { - $msg = 'In order to use artifact repository, ' . - 'you need to have zip extension enabled'; - $this->io->write($msg); - return; - } - $this->scanDirectory($this->lookup); } @@ -59,16 +56,14 @@ class ArtifactRepository extends ArrayRepository $package = $this->getComposerInformation($file); if (!$package) { if ($io->isVerbose()) { - $msg = "File {$file->getBasename()} doesn't seem to hold a package"; - $io->write($msg); + $io->write("File {$file->getBasename()} doesn't seem to hold a package"); } continue; } if ($io->isVerbose()) { $template = 'Found package %s (%s) in file %s'; - $msg = sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()); - $io->write($msg); + $io->write(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename())); } $this->addPackage($package);