卡在resolving dependencies是dns问题,非timeout能解决;卡在downloading才调http.timeout;卡在executing command需设composer_process_timeout。

Composer 安装卡住,八成不是网断了,而是你调错了参数——http.timeout 管下载,COMPOSER_PROCESS_TIMEOUT 管执行,process-timeout 配了也白配(新版已废弃)。
卡在 Resolving dependencies 是 DNS 问题,不是 timeout 能救的
这一步根本没发 HTTP 请求,Composer 只是在查域名 IP。改 http.timeout 完全无效,纯属干等。
- 先手动测镜像是否可达:
curl -I https://mirrors.aliyun.com/composer/packages.json,应秒回200 OK - 查 DNS 解析:
dig mirrors.aliyun.com @114.114.114.114,看是否返回有效 IP - 检查
/etc/hosts(Linux/macOS)或C:\Windows\System32\drivers\etc\hosts(Windows),删掉误写的packagist.org映射 - 企业网常见 DNS 污染,临时换 DNS 或切手机热点验证连通性
卡在 Downloading https://… 必须调 http.timeout,不是 process-timeout
报 cURL error 28、反复重试后静默退出、或停在 Downloading https://mirrors.aliyun.com/... —— 这才是 http.timeout 的责任区。
工作流任务拆解与模型编排技能。使用场景:(1) 收到复杂工作任务需要拆解为可执行步骤,(2) 需要为不同步骤选择最合适的模型,(3) 需要跟踪工作流进度和模型使用情况,(4) 长时间任务卡住需要问题诊断和解决方案。
- 全局设值:
composer config -g http.timeout 600(单位秒,300~600 足够) - 项目级更稳妥(CI 友好):
composer config http.timeout 600,写入当前composer.json的config段 - 临时调试优先用环境变量:
COMPOSER_HTTP_TIMEOUT=600 composer install,避免污染配置 - PHP CLI 的
default_socket_timeout仍可能干扰,可绕过:php -d default_socket_timeout=600 $(which composer) install - 同步加
http.connect_timeout 60和http.max-retries 3(Composer 2.2+ 支持)
卡在 Executing command 或报 The process timed out,只认环境变量
这时候包已下完,正在解压、跑 post-install-cmd、git clone 私有仓库,甚至执行 php artisan optimize —— process-timeout 字段在新版 Composer 中已完全失效。
- 唯一可靠方式是环境变量:
export COMPOSER_PROCESS_TIMEOUT=1200(Linux/macOS)或 Windows 系统变量 - CI 中建议设为
0(不限时),尤其首次安装或缓存失效时 - 若涉及私有 Git 仓库,确保
git自身配置正常:git config --global http.sslVerify false(仅测试环境) - 注意:设成
3600或更高可能掩盖真实问题,1200 是国内弱网下的合理上限
镜像源配错,超时再大也没用
阿里云镜像地址末尾不能带斜杠:https://mirrors.aliyun.com/composer ✅,https://mirrors.aliyun.com/composer/ ❌(会 404);且 repo.packagist 是单值字段,重复执行 composer config -g repo.packagist 会覆盖前一次。
- 确认生效:
composer config -g repos.packagist.org.url输出必须是正确镜像地址 - 禁用默认源兜底:
composer config -g packagist false,避免因下线私源逐个超时重试 - 强制走 IPv4:
COMPOSER_IPV4=1 composer install(国内多数镜像对 IPv6 支持不完整) - 镜像只加速
dist(ZIP/TAR),对source(Git clone)完全无效 —— 检查composer.json是否含"prefer-source": true或硬编码了git@地址
真正卡住的往往不是超时数字本身,而是 TLS 握手失败(比如代理自签名证书未导入)、DNS 解析异常、或 Git 协议被防火墙拦截——这些场景下,调高 timeout 只会让等待更久,却解决不了真实瓶颈。










