composer config -g 写入的是全局配置文件,Windows 下为 %APPDATA%\Composer\config.json,Linux/macOS 下为 $COMPOSER_HOME/config.json(默认 ~/.config/composer/config.json),路径不存在时自动创建,但若目录不可写则静默失败。

composer config -g 写入的是哪个文件?
全局配置写入 %APPDATA%\Composer\config.json(Windows)或 $COMPOSER_HOME/config.json(Linux/macOS),默认路径下不存在时 Composer 会自动创建。但要注意:COMPOSER_HOME 环境变量若被手动设为只读目录,或 Windows 下 %APPDATA%\Composer 目录权限不足(比如被组策略锁定),composer config -g 会静默失败,报错类似 Could not write to file,此时需手动检查该路径是否存在且可写。
http-proxy 和 https-proxy 必须同时存在
Composer 对 HTTP 和 HTTPS 请求路由是硬分离的:所有对 https://packagist.org 的请求都走 https-proxy 字段,哪怕值是 http://127.0.0.1:8080;而 http-proxy 仅用于极少数纯 HTTP 场景(如某些私有仓库未启 HTTPS)。漏配任一字段,对应协议的请求就会 fallback 到直连——现象是 composer install 卡在 Loading composer repositories,无错误提示,超时后才中断。
使用 circleci/circleci-cli 和 circleci/orb-tools-orb SDK 来组合和验证 CircleCI Orbs。自动化 orb 打包、使用 conventional-changelog 进行语义化版本控制,并发布到 CircleCI Orb Registry。
-
https-proxy值必须以http://开头(不是https://),这是 Composer 的 CONNECT 隧道约定 - 含特殊字符(
@、/、:)的密码需 URL 编码,例如pa@ss/word→pa%40ss%2Fword - 验证是否生效:运行
composer config -g --list | grep -E "(http|https)-proxy",应输出两行且格式正确
为什么 HTTP_PROXY 环境变量不生效?
Composer 明确忽略系统级 HTTP_PROXY、HTTPS_PROXY 等环境变量,只认自己配置体系内的 http-proxy 和 https-proxy 字段。这是设计使然,不是 bug。所以别指望靠 export HTTPS_PROXY=http://127.0.0.1:8080 绕过配置——它完全没用。唯一可靠方式是用 composer config -g http-proxy ... 和 composer config -g https-proxy ... 显式写入。
NTLM 代理怎么办?
Composer 原生不支持 NTLM 认证(常见于 Windows 域环境),设了 http-proxy 也会直接返回 407 Proxy Authentication Required。此时必须引入中转代理工具,例如 cntlm 或 px,让它们监听 127.0.0.1:3128 并处理 NTLM 握手,再把 Composer 的 http-proxy 和 https-proxy 都指向这个本地地址。临时验证方法:执行 curl -x http://127.0.0.1:3128 -I https://packagist.org/packages.json,如果 curl 也报 407,说明中转层没配通。
config.json 里,得一层层排除。

















