How to upgrade PHP Composer to version 2 on Plesk.

Plesk 9 (and older versions) comes with Composer V1. But a lot of modern applications require Composer V2. So how can you upgrade Plesk's internal version of Composer?

Well, there is a guide on Plesk's support website, but if you follow the instructions you will only upgrade Composer for a specific Plesk version (which will be undone when you update and is not even being used).

I commented the actual solution on the post, but as of now, they did not update the guide.

UPDATE: The author of the support post did comment on the post and he'll update the guide! You can continue reading here, or take a look at the updated guide linked in this post.

How to upgrade

  1. Check the latest installed PHP version. You can do this by opening up the /opt/plesk/php folder. Here you'll see a folder for each version. E.g.: 7.4 or 8.0
  2. Run /opt/plesk/php/PHP_VERSION/bin/php /usr/local/psa/var/modules/composer/composer.phar selfupdate --2 in your console and replace the PHP_VERSION in the command with your PHP version.
  3. Composer will now update V2.
  4. Done!