為什麼慢
由於預設情況下執行 composer 各種命令是去國外的 composer 官方映象源獲取需要安裝的具體軟體資訊,所以在不使用代理、不翻牆的情況下,從國內訪問國外伺服器的速度相對比較慢
如何修改映象源
可以使用阿里巴巴提供的 Composer 全量映象 mirrors.aliyun.com/composer/
a). 配置只在當前專案生效
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
# 取消當前專案配置
composer config --unset repos.packagist
b). 配置全域性生效
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# 取消全域性配置
composer config -g --unset repos.packagist
c). 使用第三方軟體快速修改、切換 composer 映象源
crm composer registry manager
安裝 crm
composer global require slince/composer-registry-manager
列出可用的所有映象源,前面帶 * 代表當前使用的映象
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
-- --------------- ------------------------------------------------
使用 aliyun 映象源
composer repo:use aliyun
# 執行成功之後會輸出類似以下資訊
[OK] Use the repository [aliyun] success
再次執行 composer repo:ls 命令,看到前面帶 * 的就是當前使用的映象
composer repo:ls
# 可以看到 aliyun 前面有一個 * 號,代表當前使用的是 aliyun 的源
--- --------------- ------------------------------------------------
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
--- --------------- ------------------------------------------------
更多用法檢視 crm GitHub
本作品採用《CC 協議》,轉載必須註明作者和本文連結