Composer 安装程序脚本没有 运行 正确 [退出代码 1]

The Composer installer script did not run correctly [exit code 1]

我尝试通过从 getcomposer 下载可执行文件 Composer-Setup.exe 在 Windows 10 中安装 Composer-php。当在安装过程中提示选择我想使用的命令行 PHP 时,我输入了 PHP C:\WinNMP\bin\PHPbit-php-7.4\php.exe

的路径

但是我得到了以下错误:

Script Output: PHP Warning: realpath(): open_basedir restriction in effect. 

File(C:\Users\admin\AppData\Local\Temp\is-1KBL9.tmp) 不在允许的路径内:(c:/winnmp) in C:\Users\admin\AppData\Local\Temp\is-1KBL9.tmp\installer.php 第 655 行 PHP 警告:is_writeable():open_basedir 限制生效。文件(C:\Users\admin\AppData\Local\Temp\is-1KBL9.tmp) 不在允许的路径内:(c:/winnmp) in C:\Users\admin\AppData\Local\Temp\is-1KBL9.tmp\installer.php on line 657

您的 php.ini 似乎限制了可以使用 open_basedir 选项访问哪些目录:

Limit the files that can be accessed by PHP to the specified directory-tree, including the file itself. [...]

When a script tries to access the filesystem, for example using include, or fopen(), the location of the file is checked.

您可以 运行 php -i 找出您的 php.ini 所在的位置,然后 disable/modify 该选项,例如确保 C:\Users\admin\AppData\Local\Temp 可访问。

在 90% 的情况下,问题出在 Windows 防火墙

安装时关闭 Windows Defender 防火墙

我禁用了防火墙并解决了这个作曲家问题:

脚本输出: 无法下载“https://getcomposer.org/versions”文件:php_network_getaddresses:getcomposer.org 的 getaddrinfo 失败:不知道这样的主机。

在 90% 的情况下,问题出在 Windows 防火墙。安装时关闭 Windows Defender 防火墙。