[TOC] #### 1. 前言 --- 當(dāng)我們使用 composer 安裝軟件包時(shí)是從遠(yuǎn)程的國(guó)外服務(wù)器下載的,但國(guó)內(nèi)用戶訪問國(guó)外服務(wù)器會(huì)比較慢,甚至不能訪問 國(guó)內(nèi)某些知名機(jī)構(gòu)將國(guó)外的軟件同步到了國(guó)內(nèi)服務(wù)器,將 composer 下載擴(kuò)展包用的服務(wù)器指向這個(gè)國(guó)內(nèi)服務(wù)器,就可以實(shí)現(xiàn)快速下載擴(kuò)展包了。本文列舉一些最常用的國(guó)內(nèi)鏡像 #### 2. 配置鏡像源 --- [Composer 中文網(wǎng)](https://pkg.phpcomposer.com/#how-to-use-packagist-mirror) ```bash composer config -g repo.packagist composer https://packagist.phpcomposer.com ``` [阿里云 Composer 鏡像](https://developer.aliyun.com/composer) ```bash composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ ``` [騰訊云 Composer 鏡像](https://mirrors.cloud.tencent.com/help/composer.html) ```bash composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/ ``` #### 3. 恢復(fù)默認(rèn)鏡像源 --- 刪除全局鏡像配置 ```bash # 取消全局鏡像配置,使用默認(rèn)的 https://repo.packagist.org composer config -g --unset repo.packagist ``` #### 4. 查看當(dāng)前鏡像源 --- 查看當(dāng)前全局使用的鏡像 ```bash composer config -gl composer config -gl | grep repositories.packagist.org.url ``` ![](https://img.itqaq.com/art/content/1dc19b73ae00b490d3c75cea3c01c962.png)