为 Windows 安装 Composer - 无法找到包装器“https"Composer、Windows、quot、https

2023-09-06 15:51:33 作者:▍夏殇

我正在尝试使用命令行安装 Composer for Windows:

I am trying to install Composer for Windows using the command line with the following call:

php -r "readfile(https://getcomposer.org/installer);"|php

php -r "readfile(https://getcomposer.org/installer);" | php

但是,我收到以下错误消息:

However, I get this error message:

警告:readfile():无法找到包装器https" - 您是否在配置 PHP 时忘记启用它?在第 1 行的命令行代码中

Warning: readfile(): Unable to find the wrapper "https" - did you forget to enable it when configured PHP? in Command line code on line 1

调用堆栈:0.0010 224336 1. {main}() 命令行代码:00.0010 224488 2. readfile() 命令行代码:1

Call Stack: 0.0010 224336 1. {main}() Command line code:0 0.0010 224488 2. readfile() command line code:1

警告:readfile(https://getcomposer.org/installer):打开流失败:参数无效在第 1 行的命令行代码中

Warning: readfile(https://getcomposer.org/installer): failed to open stream: invalid argument in Command line code on line 1

调用堆栈:0.0010 224336 1. {main}() 命令行代码:00.0010 224488 2. readfile() 命令行代码:1

Call Stack: 0.0010 224336 1. {main}() Command line code:0 0.0010 224488 2. readfile() Command line code:1

我已经取消了php5.5.12目录下的;extension=php_openssl.dll"这一行的注释,重启了浏览器,尝试了其他变种.当我运行命令时只删除了 https 中的s",我得到:

I have already uncommented the ";extension=php_openssl.dll" line in the php5.5.12 directory, restarted the browser, and tried other variants. When I run the command with just the 's' in https dropped, I get:

您机器上的某些设置使 Composer 无法正常工作.确保您修复了下面列出的问题并再次运行此脚本:

Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again:

缺少 openssl 扩展,这意味着无法进行安全的 HTTPS 传输.如果可能,您应该启用它或使用 --with-openssl 重新编译 php

The openssl extension is missing, which means that secure HTTPS transfers are impossible. If possible you should enable it or recompile php with --with-openssl

我已经尝试在不同的地方包含这个 --with-openssl 标志,但它似乎没有起到作用.

I've tried including this --with-openssl flag at various places but it doesn't seem to be doing the trick.

推荐答案

听起来你的安装没有启用 openssl.

This sounds like your installation hasn't got openssl enabled.

找到您的 php.ini 文件(在 Windows 上,这可能与 php.exe (c:php在我的机器上).

Locate your php.ini file (on Windows this is probably in the same place as the php.exe (c:php on my machine).

在您喜欢的编辑器中打开它,然后找到该行

Open it in your favourite editor, and locate the line

;extension=php_openssl.dll

去掉分号

extension=php_openssl.dll

HTTPS 现在应该可以在 php 中为您工作了.

HTTPS should now work for you from within php.

 
精彩推荐
图片推荐