作曲家安装参数 1 中的错误,字符 2:找不到选项 r [英] Composer install Error in argument 1, char 2: option not found r

查看:30
本文介绍了作曲家安装参数 1 中的错误,字符 2:找不到选项 r的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的网站上安装 composer.Composer 文档 建议运行以下命令:

I'm trying to install composer on my Website. The Composer documentations suggests running this command:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"`

但是当我这样做时,我得到一个错误:

but when I do, I get an error:

参数 1 中的错误,字符 2:找不到选项 r

Error in argument 1, char 2: option not found r

我使用 PHP 7.0 版

I use PHP Version 7.0

这是怎么回事?

推荐答案

我怀疑您的情况中的 php 指的是 PHP 的 CGI-SAPI 二进制文件,而不是应有的 CLI.如 PHP 手册中所述,CGI-SAPI 不包括-r 选项:

I suspect php in your case is referring to PHP's CGI-SAPI binary instead of the CLI that it should be. As documented in the PHP manual, the CGI-SAPI does not include the -r option:

注意:-r 在 CLI SAPI 中可用,但在 CGI SAPI 中不可用.

Note: -r is available in the CLI SAPI, but not in the CGI SAPI.

您可以通过使用 -v 标志检查php's"版本来确认是这种情况.

You can confirm that this is the case by checking "php's" version with the -v flag.

正确的设置应该显示 php 是一个 CLI 中断器:

Proper setup should show that php is a CLI interupter:

C:UsersHPierce>php -v
PHP 7.0.8 (cli) (built: Jun 21 2016 15:27:20) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

不正确的设置可能表明它是 CGI SAPI:

Improper setup might show that it is the CGI SAPI:

C:UsersHPierce>php-cgi -v
PHP 7.0.8 (cgi-fcgi) (built: Jun 21 2016 15:27:08)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

您可以通过使用绝对路径而不是使用操作系统的 $PATH 环境变量的 php 快捷方式引用 CLI 二进制文件来解决此问题:

You can resolve this by referencing the CLI binary with an absolute path instead of the php shortcut that utilizies your OS's $PATH environment variable:

C:phpphp.exe -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

这篇关于作曲家安装参数 1 中的错误,字符 2:找不到选项 r的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆