Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ArchiveCommand.php

function ArchiveCommand::archive

Throws

\Exception

1 call to ArchiveCommand::archive()
ArchiveCommand::execute in vendor/composer/composer/src/Composer/Command/ArchiveCommand.php
Executes the current command.

File

vendor/composer/composer/src/Composer/Command/ArchiveCommand.php, line 120

Class

ArchiveCommand
Creates an archive of a package for distribution.

Namespace

Composer\Command

Code

protected function archive(IOInterface $io, Config $config, ?string $packageName, ?string $version, string $format, string $dest, ?string $fileName, bool $ignoreFilters, ?Composer $composer) : int {
    if ($composer) {
        $archiveManager = $composer->getArchiveManager();
    }
    else {
        $factory = new Factory();
        $process = new ProcessExecutor();
        $httpDownloader = Factory::createHttpDownloader($io, $config);
        $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
        $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
    }
    if ($packageName) {
        $package = $this->selectPackage($io, $packageName, $version);
        if (!$package) {
            return 1;
        }
    }
    else {
        $package = $this->requireComposer()
            ->getPackage();
    }
    $io->writeError('<info>Creating the archive into "' . $dest . '".</info>');
    $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
    $fs = new Filesystem();
    $shortPath = $fs->findShortestPath(Platform::getCwd(), $packagePath, true);
    $io->writeError('Created: ', false);
    $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
    return 0;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal