Composer: how to update packages' repository

Sometimes we might need to use a new repository for Composer's packages, for example, in a private environment, or countries like China.

In this tutorial, we will show you how to update the packages' repository for Composer.

It is as simple as two steps to update:

  • Update to a new mirror
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
  • Update lock file
composer update --lock

Now your Composer will be reading packages from the updated repository https://mirrors.aliyun.com/composer/. Hope you find this article useful.