Can't Update to Craft 3.6 Because of Platform PHP Version

You may be trying to update to Craft 3.6 but running into this error from Composer

Image

You may be try­ing to update to Craft 3.6 but run­ning into this error from Composer:

craftcms/cms 3.6.x-dev requires php >=7.2.5 -> 
your php version (7.0; overridden via config.platform, actual: 7.4.10) 
does not satisfy that requirement.

or this warn­ing from the Craft com­mand line tool (when run­ning php craft update/info):

⚠️ This update requires PHP >=7.2.5, 
but your composer.json file is currently set to PHP 7.0.

You may also just get the no pack­ages to update or install” mes­sage from Com­pos­er. Whichev­er of those you get, here’s how to fix it.

Why does this Com­pos­er error happen?

As of Craft 3.6.0, the min­i­mum ver­sion of PHP required to run Craft CMS is 7.2.5. How­ev­er, your composer.json file still has the pri­or min­i­mum ver­sion declared in the config.platform prop­er­ty. This set­ting doesn’t impact which ver­sion your serv­er is actu­al­ly run­ning (it should be run­ning at least the new min­i­mum in order for Craft to work) but is only a pro­tec­tion against installing Craft in a unsup­port­ed serv­er environment.

How do I fix the PHP Ver­sion error?

To fix the Com­pos­er error, update your composer.json file for the Craft CMS instal­la­tion so the platform.php prop­er­ty reads 7.2.5. It should then look like this:

  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.2.5"
    }
  },

Once you have this change in place, then you can run composer update or php craft update/craft to update to the lat­est Craft CMS.