推荐设为600(10分钟)——够用又防死锁;优先通过composer_process_timeout环境变量设置,ci/cd中必须显式配置该变量以防容器重启后丢失。

process-timeout设多少才不超时
默认300秒(5分钟)在多数国内网络或私有仓库场景下根本不够用,尤其遇到大包下载、GitHub API限流或WSL2文件系统卡顿。直接设为0表示不限时,但更推荐设为600(10分钟)——够用又防死锁。
生效方式有三种,优先级从高到低:COMPOSER_PROCESS_TIMEOUT环境变量 > composer config -g process-timeout全局配置 > composer install --timeout=600命令行参数。
- CI/CD中必须用
COMPOSER_PROCESS_TIMEOUT=600,因为容器重启后composer config -g的配置会丢失 - 设为0虽能绕过超时,但掩盖了真实问题(比如
post-install-cmd里php artisan key:generate卡住),不建议日常使用 - PHP CLI内存不足也会触发假性超时,可同步加
php -d memory_limit=-1 composer.phar install
为什么换镜像源后还卡在Downloading
阿里云、腾讯云等镜像只加速packagist.org上的公共包,对git@github.com、https://gitlab.example.com这类VCS源完全无效。你看到“卡在Downloading”,大概率是正在直连私有仓库或GitHub,而没走镜像。
围绕关键发现、作用机制、临床相关性及研究局限性展开讨论。适用于撰写或优化任何生物医学论文的“讨论(Discussion)”部分——包括结果解读、与既往文献关联、阐释意外发现、界定研究局限性,以及撰写结论。当用户输入以下任一指令时也会自动触发该功能: - “write my discussion” - “help me discuss my findings” - “how do I compare to prior studies” - “write the limitations par
- 检查
composer.json里的repositories字段,删掉硬编码的packagist.org或重复镜像配置 - 执行
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/后,用composer config -g repo.packagist确认已生效 - 若项目含私有GitLab,别把它也写进
repositories里——镜像不代理VCS,反而导致Failed to clone https://xxx: could not connect to server
GitHub API 403不是网络问题,是没配Token
日志里出现https://api.github.com/请求失败、返回403或静默卡住,99%是因为GitHub每小时仅允许60次未认证API调用。换源、改DNS、开代理全无效。
- 去
https://github.com/settings/tokens/new生成Personal Access Token,只勾选repo(含public_repo)即可 - 绑定命令必须是
composer config -g github-oauth.github.com <your_token_here></your_token_here>,注意域名是github.com,不是api.github.com - 验证是否生效:
curl -H "Authorization: token <your_token_here>" https://api.github.com/rate_limit</your_token_here>,看rate.limit是否为5000
CI环境里composer install直接退出,其实是PHP扩展缺失
GitHub Actions等CI容器默认不装ext-zip、ext-xml、ext-pcntl等扩展,composer install一启动就校验失败并退出,不是超时,是根本跑不起来。
- 必须显式安装扩展:GitHub Actions中加
run: sudo apt-get update && sudo apt-get install -y zip unzip php-zip php-xml php-pcntl - 确保工作目录正确:
uses: actions/checkout@v4后加working-directory: ${{ github.workspace }},或手动cd ${{ github.workspace }} - Hyperf等框架还会检查
swoole.use_shortname = Off,CI中需在php.ini里显式设置,否则StartServer.php的checkEnvironment()会拒绝启动
真正难调的不是timeout值本身,而是分不清“真超时”和“假超时”:前者是网络或配置问题,后者常是PHP扩展缺失、脚本卡死、autoload扫描阻塞或GitHub认证失效。每次遇到卡住,先看日志里最后成功请求的是什么URL,再决定该调timeout、换源、配Token,还是装扩展。










