class Composer in Drupal 8
Same name in this branch
- 8 composer/Composer.php \Drupal\Composer\Composer
- 8 core/lib/Drupal/Core/Composer/Composer.php \Drupal\Core\Composer\Composer
Same name and namespace in other branches
- 9 composer/Composer.php \Drupal\Composer\Composer
- 10 composer/Composer.php \Drupal\Composer\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.
Hierarchy
- class \Drupal\Composer\Composer
Expanded class hierarchy of Composer
See also
https://getcomposer.org/doc/articles/scripts.md
5 files declare their use of Composer
- BuilderTest.php in core/
tests/ Drupal/ Tests/ Composer/ Generator/ BuilderTest.php - ComposerProjectTemplatesTest.php in core/
tests/ Drupal/ BuildTests/ Composer/ Template/ ComposerProjectTemplatesTest.php - ComposerTest.php in core/
tests/ Drupal/ Tests/ Composer/ ComposerTest.php - DrupalCoreRecommendedBuilder.php in composer/
Generator/ Builder/ DrupalCoreRecommendedBuilder.php - DrupalPinnedDevDependenciesBuilder.php in composer/
Generator/ Builder/ DrupalPinnedDevDependenciesBuilder.php
File
- composer/
Composer.php, line 18
Namespace
Drupal\ComposerView source
class Composer {
/**
* Update metapackages whenever composer.lock is updated.
*
* @param \Composer\Script\Event $event
*/
public static function generateMetapackages(Event $event) {
$generator = new PackageGenerator();
$generator
->generate($event
->getIO(), getcwd());
}
/**
* Ensure that the minimum required version of Composer is running.
* Throw an exception if Composer is too old.
*/
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'.");
}
}
/**
* Return the branch name the current Drupal version is associated with.
*
* @return string
* A branch name, e.g. 8.9.x or 9.0.x.
*/
public static function drupalVersionBranch() {
return preg_replace('#\\.[0-9]+-dev#', '.x-dev', \Drupal::VERSION);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Composer:: |
public static | function | Return the branch name the current Drupal version is associated with. | |
Composer:: |
public static | function | Ensure that the minimum required version of Composer is running. Throw an exception if Composer is too old. | |
Composer:: |
public static | function | Update metapackages whenever composer.lock is updated. |