The new core_version_requirement key in *.info.yml files for modules, themes, and profiles now supports semantic versioning as implemented by the Composer project. This allows modules, themes, and profiles to also specify that they are compatible with multiple major versions of Drupal core.

For example a module that is compatible with Drupal 8 and Drupal 9 can have a info.yml file like this

name: My Module type: module core: 8.x core_version_requirement: ^8 || ^9

This specifies that the module is compatible with all versions of Drupal 8 and 9. The core: is required here because Drupal Core versions before 8.7.7 do not recognize the core_version_requirement: key.

Most modules however will have to remove deprecated code to be compatible with Drupal 9. Therefore they will not able to be compatible with all versions of Drupal 8.

For example a module that is compatible with Drupal 8 versions after Drupal 8.8.0 and also Drupal 9 will need a info.yml file like this:

name: My Module type: module core_version_requirement: ^8.8 || ^9

The core: key must not be used here to make sure that versions of Drupal before 8.7.7 will not install the module. Adding both core and core_version_requirement with anything other than core_version_requirement: ^8 || ^9 will result in an exception.

The core_version_requirement cannot be used to restrict to core version before 8.7.7. For instance, core_version_requirement: ^8.7 || ^9 would throw a parsing exception: This is not valid because ^8.7 would include versions like 8.7.0 which do not recognize the core_version_requirement: key.

It is important when using the new core_version_requirement key with anything other than core_version_requirement: ^8 || ^9 that module be tested on Drupal 8.7.7 or later.

It is also possible to specify the same requirement in composer.json, but if no drupal/core requirement is defined there, one will automatically be generated based on core_version_requirement . This has been implemented in #3084063: Use information in info.yml files to determine project requirements.

{ "require": { "drupal/core": "^8.7.7 || ^9" } }

Test modules

Note that test modules can omit the core_version_requirement key entirely as of Drupal 8.8.2, so that they will work with any core version they are tested against. Prior to 8.8.2, the value is required for test modules and will cause site errors if it is not included. These errors are even encountered if $settings['extension_discovery_scan_tests'] = TRUE; is not enabled in settings.php.

Add the following to test module info.yml files: