Composer 国内加速,修改镜像源

Composer 国内加速,修改镜像源

binscor
2021-01-07 / 0 评论 / 406 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年09月09日,已超过1129天没有更新,若内容或图片失效,请留言反馈。

参考链接:

Composer 国内加速,修改镜像源

1. 配置只在当前项目生效

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

#取消当前项目配置
composer config --unset repos.packagist

2. 配置全局生效

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

# 取消全局配置
composer config -g --unset repos.packagist

3. 使用第三方软件快速修改、切换 composer 镜像源

安装 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

0

评论 (0)

取消