There is no problem with installing Composer globally, but there may be a problem with using composer global require
to install individual Composer-managed projects globally.
You should not run in to this trouble just using Composer on the server to composer install
your various Drupal 8 and Drupal 9 sites, but you should be aware of the potential for dependency conflicts, especially in local development environments.
To avoid this, use consolidation/cgr
instead of composer global require
:
$ composer global require consolidation/cgr
After globally requiring that one package, you can use cgr
as a drop-in replacement for composer global require
and it will prevent dependency conflicts with globally-installed packages. For example, to install Drush globally:
$ cgr drush/drush
Note that current best practices now say to install a site-local Drush by adding Drush as a dependency of your Composer-managed Drupal project; I just used this as an example of how to use cgr
.
By the way, if you are still running Drupal 8 sites, please be aware that Drupal 8 reaches its end of life on November 1, 2021. Here are some tips on upgrading Drupal 8 to Drupal 9.