You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用composersetup.exe安装Composer失败,求助解决并创建Laravel项目

解决Composer安装时无法连接getcomposer.org的报错问题

你遇到的报错内容:

The Composer installer script was not successful [exit code 1]. Your proxy settings may be causing this error. Script Output: The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: No connection could be made because the target machine actively refused it.

试试下面这些解决方案:

  • 检查并调整代理设置

    1. 先确认系统是否开启了不必要的代理:打开Windows「Internet选项」→「连接」→「局域网设置」,取消勾选不需要的代理选项。
    2. 如果是公司网络必须使用代理,打开命令提示符,执行以下命令配置Composer代理(替换成你的实际代理地址和端口):
      composer config -g http.proxy http://your-proxy-address:port
      composer config -g https.proxy https://your-proxy-address:port
      
    3. 同时切换国内Composer镜像,提升连接稳定性:
      composer config -g repo.packagist composer https://packagist.phpcomposer.com
      
  • 手动安装Composer

    1. 直接下载composer.phar文件,放到你的PHP安装目录(比如C:\php)。
    2. 在同一目录下创建composer.bat文件,写入内容:
      @php "%~dp0composer.phar" %*
      
    3. 把PHP安装目录添加到系统环境变量PATH中,之后就能在任意命令行窗口调用composer命令。
  • 临时关闭防火墙/杀毒软件
    部分防火墙或杀毒软件会拦截Composer的网络请求,安装前暂时关闭它们,完成后再重新开启。

  • 切换网络环境
    如果是公司网络限制导致的问题,试试切换到手机热点等其他网络,确认是否能正常完成安装。

内容的提问来源于stack exchange,提问作者Ahed Suliman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 07:30:46