Composer Domestic Acceleration, Modification of Mirror Source

Keywords: Programming PHP Laravel

Why slow?

Because composer commands are executed by default to obtain specific software information from composer official mirror source abroad, the speed of accessing foreign servers from home is relatively slow without using proxy and turning over the wall.

How to Modify Mirror Source

You can use the Composer full volume mirrors provided by you. https://mirrors.aliyun.com/composer/

Configuration only takes effect on current projects

composer config repo.packagist composer https://mirrors.aliyun.com/composer/

# Cancel current project configuration
composer config --unset repos.packagist

B. Configuration takes effect globally

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# Cancel global configuration
composer config -g --unset repos.packagist

C. Use third-party software to quickly modify and switch composer image sources

crm composer registry manager

Install crm

composer global require slince/composer-registry-manager

List all available mirror sources, with * in front representing the currently used image

composer repo:ls

-- --------------- ------------------------------------------------
     composer        https://packagist.org
     phpcomposer     https://packagist.phpcomposer.com
     aliyun          https://mirrors.aliyun.com/composer
     tencent         https://mirrors.cloud.tencent.com/composer
     huawei          https://mirrors.huaweicloud.com/repository/php
     laravel-china   https://packagist.laravel-china.org
     cnpkg           https://php.cnpkg.org
     sjtug           https://packagist.mirrors.sjtug.sjtu.edu.cn
-- --------------- ------------------------------------------------

Using aliyun mirror source

composer repo:use aliyun

# After successful execution, the following information is output
[OK] Use the repository [aliyun] success

Execute the composer repo:ls command again, and see that the image in front of * is the one currently in use.

composer repo:ls

# You can see that there is a * sign in front of aliyun, which indicates that the source of aliyun is currently in use.
--- --------------- ------------------------------------------------
      composer        https://packagist.org
      phpcomposer     https://packagist.phpcomposer.com
  *   aliyun          https://mirrors.aliyun.com/composer
      tencent         https://mirrors.cloud.tencent.com/composer
      huawei          https://mirrors.huaweicloud.com/repository/php
      laravel-china   https://packagist.laravel-china.org
      cnpkg           https://php.cnpkg.org
      sjtug           https://packagist.mirrors.sjtug.sjtu.edu.cn
--- --------------- ------------------------------------------------

Posted by aladiyat23 on Mon, 07 Oct 2019 01:47:09 -0700