硬编码外网地址导致超时,镜像源无效:Composer 会绕过镜像直连 GitHub、raw.githubusercontent.com 等硬编码 URL;需用 composer config --list | grep repositories 检查私有源,grep -r 扫描项目代码定位地址,临时屏蔽可用 hosts 截断或 --no-scripts --no-plugins 跳过执行,替换 vendor 内容需谨慎并锁死版本。

硬编码外网地址导致的超时,镜像源完全无效
镜像只代理 repo.packagist.org 的元数据和 dist 包(ZIP/TAR),但项目或依赖包里如果写了 https://github.com/xxx、git@github.com:xxx 或 https://raw.githubusercontent.com/xxx 这类地址,Composer 会绕过镜像直连——此时换源毫无作用,超时就卡在这一步。
典型表现是 composer install -vvv 最后一行停在:Downloading https://raw.githubusercontent.com/somevendor/config/master/config.json 或 Cloning git@github.com:someorg/private-repo.git
- 先用
composer config --list | grep repositories检查全局是否误加了私有源 - 再搜项目代码:
grep -r "github.com\|raw.githubusercontent.com\|gitlab.com" . --include="*.json" --include="*.php" --include="*.xml" - 重点盯
composer.json里的repositories字段,以及第三方包的install脚本、post-install-cmd中的file_get_contents或curl_exec调用
临时屏蔽外网请求:用 hosts 或 DNS 截断
不是所有硬编码都能改,尤其闭源包或 Composer 插件。这时最稳的办法是让请求根本发不出去,逼它 fallback 或报错退出,而不是无限等待超时。
例如某包在 Plugin::activate() 里硬连 api.example.com,你可以:
- Linux/macOS:往
/etc/hosts加一行127.0.0.1 api.example.com - Windows:修改
C:\Windows\System32\drivers\etc\hosts,同样加127.0.0.1条目 - 或者统一换 DNS:设为
114.114.114.114,对国内未备案域名直接返回 NXDOMAIN,比超时快得多
注意:别用 0.0.0.0,某些 PHP cURL 版本会把它当无效地址重试三次。
强制跳过 problematic scripts
很多超时发生在 post-install-cmd 或插件的 activate() 阶段,它们不走 Composer 下载逻辑,而是自己发起 HTTP 请求。这类脚本没法被镜像加速,也难 patch。
围绕关键发现、作用机制、临床相关性及研究局限性展开讨论。适用于撰写或优化任何生物医学论文的“讨论(Discussion)”部分——包括结果解读、与既往文献关联、阐释意外发现、界定研究局限性,以及撰写结论。当用户输入以下任一指令时也会自动触发该功能: - “write my discussion” - “help me discuss my findings” - “how do I compare to prior studies” - “write the limitations par
安全跳过方式只有两种:
- 安装时禁用脚本:
composer install --no-scripts --no-plugins,之后手动确认是否真需要那些功能 - 临时覆盖脚本:在
composer.json里把对应命令替换成空数组,如"post-install-cmd": [],而非删掉字段(有些插件会 fallback 到默认行为)
别用 --ignore-platform-reqs,它只管扩展依赖,不拦网络请求。
替换 vendor 内部硬编码(谨慎操作)
如果确定是某个已知包的问题(比如某 SDK 固定读取 https://cdn.jsdelivr.net/npm/xxx.js),且你有权修改 vendor,可直接 sed 替换:
sed -i '' 's|https://cdn.jsdelivr.net|https://cdn.jsdelivr.net/npm/xxx.js|g' vendor/some/package/src/Loader.php
但要注意:
- 替换后必须加
composer dump-autoload,否则 autoload cache 还在用旧路径 - 这种修改会被
composer update覆盖,建议配合composer.lock锁死版本,或提 PR 给上游 - PHP 8.3+ 的 opcache 可能缓存了旧字节码,执行前先
opcache_reset()或重启 CLI 进程
真正麻烦的从来不是配置本身,而是你不知道哪行代码在后台偷偷连外网——-vvv 输出要逐行看,别只盯着 “Downloading” 行。

















