php Composer 安装错误 - 实际启用时需要 ext_curl

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19335305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 19:17:51  来源:igfitidea点击:

Composer install error - requires ext_curl when it's actually enabled

phpwindowscurlfacebook-php-sdkcomposer-php

提问by Michal Artazov

I'm trying to install Facebook PHP SDK with Composer. This is what I get

我正在尝试使用 Composer 安装 Facebook PHP SDK。这就是我得到的

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

    Problem 1
        - Installation request for facebook/php-sdk dev-master -> satisfiable by facebook/php-sdk[dev-master].
        - facebook/php-sdk dev-master requires ext-curl * -> the requested PHP extension curl is missing from your system.

Problem is, I have curl extension enabled (uncommented in php.ini). When I run phpinfo(), it says it's enabled. Only clue I have is that when I run $ php -m, 'curl' line is missing but I don't know what to do about it.

问题是,我启用了 curl 扩展(在 php.ini 中未注释)。当我运行时phpinfo(),它说它已启用。我唯一的线索是,当我运行时$ php -m,缺少 'curl' 行,但我不知道该怎么办。

I have wamp 2.4 on Win8 and I'm running composer in cmd.exe.

我在 Win8 上有 wamp 2.4,我在 cmd.exe 中运行 composer。

回答by Adriano Rosa

This is caused because you don't have a library php5-curl installed in your system,

这是因为您的系统中没有安装库 php5-curl,

On Ubuntu its just simple run the line code below, in your case on Xamp take a look in Xamp documentation

在 Ubuntu 上,它只是简单地运行下面的行代码,在 Xamp 的情况下,请查看 Xamp 文档

sudo apt-get install php5-curl

For anyone who uses php7.0

对于任何使用 php7.0 的人

sudo apt-get install php7.0-curl

For those who uses php7.1

对于使用php7.1的人

sudo apt-get install php7.1-curl

For those who use php7.2

对于使用php7.2的人

sudo apt-get install php7.2-curl

Or simply run below command to install by your version:

或者只需运行以下命令即可按您的版本进行安装:

sudo apt-get install php-curl

回答by user2998553

This worked for me: http://ubuntuforums.org/showthread.php?t=1519176

这对我有用http: //ubuntuforums.org/showthread.php?t=1519176

After installing composer using the command curl -sS https://getcomposer.org/installer | phpjust run a sudo apt-get updatethen reinstall curl with sudo apt-get install php5-curl. Then composer's installation process should work so you can finally run php composer.phar installto get the dependencies listed in your composer.json file.

使用命令安装 composer 后,curl -sS https://getcomposer.org/installer | php只需运行 asudo apt-get update然后重新安装 curl sudo apt-get install php5-curl。然后 Composer 的安装过程应该可以工作,这样您就可以最终运行php composer.phar install以获取 composer.json 文件中列出的依赖项。

回答by Michal Artazov

As Danack said in comments, there are 2 php.ini files. I uncommented the line with curl extension in the one in Apache folder, which is php.ini used by the web server.

正如 Danack 在评论中所说,有 2 个 php.ini 文件。我取消了 Apache 文件夹中带有 curl 扩展名的行的注释,该文件夹是 Web 服务器使用的 php.ini。

Composer, on the other hand, uses php for console which is a whole different story. Php.ini file for that program is not the one in Apache folder but it's in the PHP folder and I had to uncomment the line in it too. Then I ran the installation again and it was OK.

另一方面,Composer 使用 php 作为控制台,这是一个完全不同的故事。该程序的 Php.ini 文件不是 Apache 文件夹中的文件,但它在 PHP 文件夹中,我也必须取消注释其中的行。然后我再次运行安装,一切正常。

回答by Grigoreas P.

on php7 run for example:

例如在 php7 上运行:

> sudo apt-get install php-curl
> sudo apt-get install php-mbstring

for every missing extension. Then:

对于每个缺少的扩展名。然后:

> sudo apt-get update

and finally (in the project's root folder):

最后(在项目的根文件夹中):

> composer install

回答by user3497737

I ran into the same issue trying to install Dropbox SDK.

我在尝试安装 Dropbox SDK 时遇到了同样的问题。

CURL was indeed enabled on my system but this meant by the php.ini in the wamp\bin\apache folder.

CURL 确实在我的系统上启用,但这意味着 wamp\bin\apache 文件夹中的 php.ini。

I simply had to manually edit the php.ini situated in wamp\bin\php, uncomment the extension=php_curl.dllline, restart Wamp and it worked perfectly.

我只需要手动编辑位于 wamp\bin\php 的 php.ini,取消注释该extension=php_curl.dll行,重新启动 Wamp,它就完美运行了。

Why there are those 2 php.ini and only one is used is still a mystery for me...

为什么有那两个 php.ini 而只有一个被使用对我来说仍然是个谜......

Hope it's helpul to someone!

希望它对某人有帮助!

回答by Aaron Wright

I had this problem after upgrading to PHP5.6. My answer is very similar to Adriano's, except I had to run:

升级到 PHP5.6 后我遇到了这个问题。我的回答与阿德里亚诺的非常相似,只是我必须跑:

sudo apt-get install php5.6-curl

Notice the "5.6". Installing php5-curl didn't work for me.

注意“5.6”。安装 php5-curl 对我不起作用。

回答by Sven

According to https://github.com/composer/composer/issues/2119you could extend your local composer.jsonto state that it provides the extension (which it doesn't really do - that's why you shouldn't publicly publish your package, only use it internally).

根据https://github.com/composer/composer/issues/2119,您可以扩展您的本地composer.json以声明它提供了扩展(实际上并没有这样做 - 这就是为什么您不应该公开发布您的包,只有在内部使用它)。

回答by Gratus D.

I ran into a similar issue when trying to get composer to install some dependencies. It turns out the .dll my version of Wamp came with had a conflict, I am guessing, with 64 bit Windows.

我在尝试让 Composer 安装一些依赖项时遇到了类似的问题。事实证明,我的 Wamp 版本附带的 .dll 与 64 位 Windows 存在冲突,我猜。

This url has fixed curl dlls: http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

这个网址有固定的 curl dll:http: //www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/

Scroll down to the section that says: Fixed Curl Extensions.

向下滚动到以下部分:固定卷曲扩展。

I downloaded "php_curl-5.4.3-VC9-x64.zip". I just overwrote the dll inside the wamp/bin/php/php5.4.3/ext directory with the dll that was in the zip file and composer worked again.

我下载了“php_curl-5.4.3-VC9-x64.zip”。我只是用 zip 文件中的 dll 覆盖了 wamp/bin/php/php5.4.3/ext 目录中的 dll,然后 composer 再次工作。

I am running 64 bit Windows 8.

我正在运行 64 位 Windows 8。

Hope this helps.

希望这可以帮助。

回答by Sujal Patel

Enable in php 7 try below command

在 php 7 中启用试试下面的命令

sudo apt-get install php7.0-curl

回答by Emily

For anyone who encounters this issue on Windows i couldn't find my answer on google at all. I just tried running composer require ext-curland this worked. Alternatively add the following in your composer.json file:

对于在 Windows 上遇到此问题的任何人,我根本无法在 google 上找到我的答案。我只是尝试运行composer require ext-curl并且这有效。或者在 composer.json 文件中添加以下内容:

"require": {
"ext-curl": "^7.3"
}