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

Breadcrumb

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

function ShowCommand::printMeta

Prints package metadata.

Parameters

array<string, string> $versions:

1 call to ShowCommand::printMeta()
ShowCommand::printPackageInfo in vendor/composer/composer/src/Composer/Command/ShowCommand.php
Prints package info.

File

vendor/composer/composer/src/Composer/Command/ShowCommand.php, line 879

Class

ShowCommand
@author Robert Schönthal <seroscho@googlemail.com> @author Jordi Boggiano <j.boggiano@seld.be> @author Jérémy Romey <jeremyFreeAgent> @author Mihai Plasoianu <mihai@plasoianu.de>

Namespace

Composer\Command

Code

protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null) : void {
    $isInstalledPackage = !PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package);
    $io = $this->getIO();
    $io->write('<info>name</info>     : ' . $package->getPrettyName());
    $io->write('<info>descrip.</info> : ' . $package->getDescription());
    $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: []));
    $this->printVersions($package, $versions, $installedRepo);
    if ($isInstalledPackage && $package->getReleaseDate() !== null) {
        $io->write('<info>released</info> : ' . $package->getReleaseDate()
            ->format('Y-m-d') . ', ' . $this->getRelativeTime($package->getReleaseDate()));
    }
    if ($latestPackage) {
        $style = $this->getVersionStyle($latestPackage, $package);
        $releasedTime = $latestPackage->getReleaseDate() === null ? '' : ' released ' . $latestPackage->getReleaseDate()
            ->format('Y-m-d') . ', ' . $this->getRelativeTime($latestPackage->getReleaseDate());
        $io->write('<info>latest</info>   : <' . $style . '>' . $latestPackage->getPrettyVersion() . '</' . $style . '>' . $releasedTime);
    }
    else {
        $latestPackage = $package;
    }
    $io->write('<info>type</info>     : ' . $package->getType());
    $this->printLicenses($package);
    $io->write('<info>homepage</info> : ' . $package->getHomepage());
    $io->write('<info>source</info>   : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
    $io->write('<info>dist</info>     : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
    if ($isInstalledPackage) {
        $path = $this->requireComposer()
            ->getInstallationManager()
            ->getInstallPath($package);
        if (is_string($path)) {
            $io->write('<info>path</info>     : ' . realpath($path));
        }
        else {
            $io->write('<info>path</info>     : null');
        }
    }
    $io->write('<info>names</info>    : ' . implode(', ', $package->getNames()));
    if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
        $replacement = $latestPackage->getReplacementPackage() !== null ? ' The author suggests using the ' . $latestPackage->getReplacementPackage() . ' package instead.' : null;
        $io->writeError(sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement));
    }
    if ($package->getSupport()) {
        $io->write("\n<info>support</info>");
        foreach ($package->getSupport() as $type => $value) {
            $io->write('<comment>' . $type . '</comment> : ' . $value);
        }
    }
    if (\count($package->getAutoload()) > 0) {
        $io->write("\n<info>autoload</info>");
        $autoloadConfig = $package->getAutoload();
        foreach ($autoloadConfig as $type => $autoloads) {
            $io->write('<comment>' . $type . '</comment>');
            if ($type === 'psr-0' || $type === 'psr-4') {
                foreach ($autoloads as $name => $path) {
                    $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
                }
            }
            elseif ($type === 'classmap') {
                $io->write(implode(', ', $autoloadConfig[$type]));
            }
        }
        if ($package->getIncludePaths()) {
            $io->write('<comment>include-path</comment>');
            $io->write(implode(', ', $package->getIncludePaths()));
        }
    }
}

API Navigation

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