function Composer::ensureComposerVersion

Same name in other branches
  1. 9 composer/Composer.php \Drupal\Composer\Composer::ensureComposerVersion()
  2. 10 composer/Composer.php \Drupal\Composer\Composer::ensureComposerVersion()
  3. 11.x composer/Composer.php \Drupal\Composer\Composer::ensureComposerVersion()

Ensure that the minimum required version of Composer is running. Throw an exception if Composer is too old.

1 call to Composer::ensureComposerVersion()
ComposerTest::testEnsureComposerVersion in core/tests/Drupal/Tests/Composer/ComposerTest.php
Verify that Composer::ensureComposerVersion() doesn't break.

File

composer/Composer.php, line 34

Class

Composer
Provides static functions for composer script events. See also core/lib/Drupal/Composer/Composer.php, which contains similar scripts needed by projects that include drupal/core. Scripts that are only needed by drupal/drupal go here.

Namespace

Drupal\Composer

Code

public static function ensureComposerVersion() {
    $composerVersion = method_exists(ComposerApp::class, 'getVersion') ? ComposerApp::getVersion() : ComposerApp::VERSION;
    if (Comparator::lessThan($composerVersion, '1.9.0')) {
        throw new \RuntimeException("Drupal core development requires Composer 1.9.0, but Composer {$composerVersion} is installed. Please run 'composer self-update'.");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.