Score:0

upgrade_status - unexpected error about PHP version

ru flag

I'm doing preparatory work for upgrading a site from D8 to D9...

The Drupal dev site (macOS 10.14.6 served with Laravel Vagrant) is running PHP 7.3.28, both on command line and php-fpm, and I'm seeing the correct version with php --version and at /admin/reports/status

And yet, whenever I scan my custom modules via the upgrade_status UI, I consistently get:

PHPStan command failed:

/Users/wt/Sites/sitename/vendor/bin/phpstan analyse --error-format=json -c /tmp/upgrade_status/deprecation_testing.neon /Users/wt/Sites/sitename/web/modules/custom/snape 2> /tmp/upgrade_status/phpstan_error_output

Command output:

Empty.

Command error:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". You are running 7.1.33. in /Users/wt/Sites/sitename/vendor/composer/platform_check.php on line 24

If I run phpstan manually using the first command, it works (though annoyingly the JSON output is truncated).

I've been going through this question as well.

  • adding "config": { "platform-check": false } doesn't work
  • adding "config": { "platform": { "php": "7.4" } doesn't work

I've checked the user PHP is running as; it's me, the same as via CLI. I've also done which php version on a bunch of other possible users and they all go to /usr/local/bin/php, which has the correct PHP version.

I've installed drupal/core-dev and phpunit to try and avoid any issues with the upgrade_status module. I have the latest version of it.

It runs correctly on production (Debian 10).

Score:1
cn flag

Run composer -vvv about. Find the line that looks like:

"Running X.X.X (XXXX) with PHP X.X.XX on XXXX".

This will tell you what php composer is using. If this is different, you sometimes need to force the php version you want to use either via bashrc or some other method. For example, I have a site hosted on a cpanel server with multiphp, and have this in a my .bashrc file:

alias php="/usr/local/bin/ea-php74"
alias composer="php /opt/cpanel/composer/bin/composer"

Note: On that same cpanel server, we were able to solve this globally by setting the system php to php 7.4. Along with that, we made sure to add this to each composer project, so even if the system PHP is higher, we can tell composer what deps to install:

"config": {
  "platform": {
    "php": "7.4"
  }
},
ru flag
In my case, that's giving me the correct version as well, and hardcoding the platform in composer.json isn't making a difference… I'll edit the question, but for now I'm running the scans on production (a Debian server) to identify the errors.
cn flag
After you hardcode the platform php in composer json, make sure you run a `composer update`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.