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

Breadcrumb

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

function InstalledVersions::getVersion

Same name in this branch
  1. 11.1.x vendor/composer/composer/src/Composer/InstalledVersions.php \Composer\InstalledVersions::getVersion()

Parameters

string $packageName:

Return value

string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present

File

vendor/composer/InstalledVersions.php, line 173

Class

InstalledVersions
This class is copied in every Composer installed project and available to all

Namespace

Composer

Code

public static function getVersion($packageName) {
    foreach (self::getInstalled() as $installed) {
        if (!isset($installed['versions'][$packageName])) {
            continue;
        }
        if (!isset($installed['versions'][$packageName]['version'])) {
            return null;
        }
        return $installed['versions'][$packageName]['version'];
    }
    throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}

API Navigation

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