From 63867f9bd724caa2a486518c53973e90dcd9c99f Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 13 May 2024 20:21:01 +1000 Subject: [PATCH] [#462] Removed PHP version from `composer.json`. --- README.md | 33 +++++++++++++++++++++++++++------ composer.json | 1 - 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 73c3e4938..50a089ac3 100644 --- a/README.md +++ b/README.md @@ -123,15 +123,36 @@ section of composer.json: ### How do I specify a PHP version? -This project supports PHP 8.3 as minimum version (see [PHP requirements](https://www.drupal.org/docs/system-requirements/php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 8.3+. +There are 2 places where Composer will be looking for PHP version requirements +when resolving dependencies: +1. The `require.php` version value in `composer.json`. +2. The `config.platform` version value in `composer.json`. -To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: +The purpose of `require.php` is to set the minimum PHP language requirements +for a package. For example, the minimum version required for Drupal 11.0 is +`8.3` or above, which can be specified as `>=8.3`. + +The purpose of `config.platform` is to set the PHP language requirements for the +specific instance of the package running in the current environment. For +example, while the minimum version required for Drupal 11 is `8.3` or above, +the actual PHP version on the hosting provider could be `8.3.1`. The value of +this field should provide your exact version of PHP with all 3 parts of the +version. + +#### Which versions to specify in my Drupal site? + +This project includes `drupal/core` which already has `require.php` added. Your +would inherit that constraint. There is no need to add `require.php` to your +`composer.json`. + +`config.platform` is a platform-specific. It is recommended to specify +`config.platform` as a _specific version_ (e.g.`8.3.1`) constraint to ensure +that only the package versions supported by your current environment are used. ```json "config": { - "sort-packages": true, - "platform": { - "php": "8.3.1" - } + "platform": { + "php": "8.3.1" + } }, ``` diff --git a/composer.json b/composer.json index 24656a9d6..29b7066e6 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,6 @@ } ], "require": { - "php": ">=8.3", "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", "drupal/core-composer-scaffold": "^11@alpha",