271

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

$ 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.

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Michal Artazov
  • 4,368
  • 8
  • 25
  • 38
  • 7
    Run "php -i | grep php.ini" to make sure you're editing the correct ini file for PHP? – Danack Oct 12 '13 at 16:40
  • 3
    Composer will ask the currently running PHP for the extensions, which is the command line version of PHP, not the server version. If THAT PHP does not have the curl extension, it will not work. That is probably a shortcoming of the current implementation of Composer, because grabbing remote packages does not require the extensions, and the server used to grab packages must not be the server used to execute things. – Sven Oct 12 '13 at 21:30

18 Answers18

628

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

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

sudo apt-get install php5-curl

For anyone who uses php7.0

sudo apt-get install php7.0-curl

For those who uses php7.1

sudo apt-get install php7.1-curl

For those who use php7.2

sudo apt-get install php7.2-curl

For those who use php7.3

sudo apt-get install php7.3-curl

For those who use php7.4

sudo apt-get install php7.4-curl

For those who use php8.0

sudo apt-get install php8.0-curl

Or simply run below command to install by your version:

sudo apt-get install php-curl
LeGmask
  • 3
  • 2
Adriano Rosa
  • 8,303
  • 1
  • 25
  • 25
  • 27
    The question's author seems to be running Windows. Windows is not based on Debian. – huertanix May 14 '15 at 16:46
  • 5
    @huertanix despite the user's system is running on, the question error is because curl library is not installed on the system which may cause composer error, what I point out is just an example to clarify the user how to fix that. – Adriano Rosa May 15 '15 at 03:05
  • 4
    at ubuntu 16 with php 5.6 you should use sudo apt-get install php5.6-curl – barak Jul 31 '16 at 12:56
  • Now getting this: E: Unable to locate package php5-curl – vnchopra Sep 19 '16 at 01:25
  • 5
    Solved with this "sudo apt-get install php-curl" – vnchopra Sep 19 '16 at 04:17
  • 6
    php-curl is a meta-package that makes the solution independent from php version. So "sudo apt-get install php-curl" is the universal answer – Max Oct 26 '16 at 13:50
  • 1
    you shouldn't specify the version number if you dont explicitly need it. otherwise you might accidentally install an older version.use `php-curl` instead, which as of today will install `php7.0-curl`. – phil294 Dec 16 '16 at 00:07
  • Now it's php7.2-curl :) – Kacifer Jan 11 '18 at 17:05
  • ` sudo apt-get install php-curl ` installed version 7.2 for me and my server is running 7.1 – Dazzle Jun 16 '19 at 15:05
  • @Dazzle sudo apt-get install php-curl will always install the latest version of the package in your system, should you try: sudo apt-get install php7.1-curl the get the exact version – Adriano Rosa Jun 18 '19 at 16:41
  • I understand that 7.1-curl will install the specific version but the general command installed 7.2 for me even though I am running 7.1 – Dazzle Jun 18 '19 at 21:33
  • I see, I'd suggest running: `sudo apt-cache show php` to check which is the latest version php in your system. Sometimes the system may have multiple versions of php as well, you can also check which one is the default by running: `sudo update-alternatives --config php`, if so you may switch like so: `sudo update-alternatives --set php /usr/bin/php7.1` – Adriano Rosa Jun 19 '19 at 03:25
  • On Ubuntu 18 running in WSL on Win10, php7.2, `sudo apt-get install php-curl` failed with a 404 for me, but `sudo apt-get install php7.2-curl` succeeded. After that, I needed to do `sudo apt-get update`, then perform the same process for several other missing extensions, after which `composer install` succeeded. Note that to see which versions of a missing extension are available for your system you can do `apt-cache search `. E.x. for `php-curl` extension, do `apt-cache search php-curl` to find versions of `php-curl` extension available for your system. – kenS Apr 16 '20 at 20:19
  • E: Unable to locate package php7.2-curl – JRichardsz Feb 04 '22 at 06:50
  • Thanks, this worked for me. Just be sure to restart apache. – Gustavo Martínez Apr 03 '23 at 20:11
116

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

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

user2998553
  • 1,278
  • 1
  • 8
  • 8
34

on php7 run for example:

> 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
Grigoreas P.
  • 2,452
  • 25
  • 19
27

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.

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.

Michal Artazov
  • 4,368
  • 8
  • 25
  • 38
13

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

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

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

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

Hope it's helpul to someone!

user3497737
  • 161
  • 1
  • 2
  • One php.ini is used by Apache within WAMP and the other is used when starting the built in PHP web server like this: `$ php -S localhost:8000` in the console – Yahya Uddin Mar 29 '15 at 20:57
  • Thank you man, it works perfectly !! Don't understand why php_curl is checked and with a `;` in the php.ini file ... – w3spi Jun 01 '15 at 22:08
12

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

sudo apt-get install php5.6-curl

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

Aaron Wright
  • 168
  • 2
  • 6
7

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-curl and this worked. Alternatively add the following in your composer.json file:

"require": {
"ext-curl": "^7.3"
}
Emily
  • 79
  • 1
  • 1
  • Please share more details such that others can learn from it. If Composer complains that `ext-curl` is already missing, how could adding it to the `composer.json` resolve the problem? That doesn't magically install cURL (as Composer does not install extensions) – Nico Haase Oct 31 '21 at 06:55
6

According to https://github.com/composer/composer/issues/2119 you could extend your local composer.json to 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).

Sven
  • 69,403
  • 10
  • 107
  • 109
  • Weird, how does it work? Do you mean that composer loads the extension itself? – Pacerier Aug 11 '15 at 17:08
  • Composer first builds a list of stuff that should be present, and then searches for stuff that satisfies this requirement list. PHP extensions installed simply are an entry in the list that is available to satisfy requirements. Packages that `provide` a package that is named the same as a PHP extension would also satisfy the requirements, because at the stage of comparing required and existing stuff, an extension is simply a string just like a library package name. – Sven Aug 25 '15 at 20:53
4

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.

This url has fixed curl dlls: 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.

I am running 64 bit Windows 8.

Hope this helps.

Gratus D.
  • 787
  • 7
  • 22
4

if use wamp go to:

wamp\bin\php\php.5.x.x\php.ini find: ;extension=php_curl.dll remove (;)

4

Enable in php 7 try below command

sudo apt-get install php7.0-curl
Sujal Patel
  • 2,444
  • 1
  • 19
  • 38
4

Not sure why an answer with Linux commands would get so many up votes for a Windows related question, but anyway...

If phpinfo() shows Curl as enabled, yet php -m does NOT, it means that you probably have a php-cli.ini too. run php -i and see which ini file loaded. If it's different, diff it and reflect and differences in the CLI ini file. Then you should be good to go.

Btw download and use Git Bash instead of cmd.exe!

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39
2

I have Archlinux with php 7.2, which has Curl integrated, so no amount of configuration voodoo would make Composer see ext-curl, that PHP could see and work with happily. Work around is to use Composer with --ignore-platform-reqs.

eg composer update --ignore-platform-reqs

Reference = https://github.com/composer/composer/issues/1426

Onyx
  • 876
  • 1
  • 10
  • 18
2

try install php5-curl by using below snippet.

sudo apt-get install php5-curl

if it won't work try below code i m sure it will work fine.

sudo apt-get install php-curl

for me it worked... all the best :)

2

If you are ubuntu, this will work for you.

composer update --ignore-platform-reqs
ojames314
  • 29
  • 3
1

for ubuntu 20.* this will work.

sudo apt-get install php-curl
Namatullah Shahbazi
  • 236
  • 1
  • 8
  • 21
0

In my case I moved from PHP5 to PHP7 and I ve got this error, Simply go to your /bin/php/php7/php.ini , then uncomment extension=php_curl.dll and restart your server, re-run your composer install.

Inoubli
  • 374
  • 2
  • 11
0

If you getting error like php7.2-curl doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this

You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.

apt-get install aptitude

Now you have to check if aptitude can download it or not if download it follow instructions

sudo aptitude install php7.2-curl

If you have gotten any error like this

E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'

Any type on error i'm not talking about proper these errors

Try to add php package again

sudo apt-add-repository ppa:ondrej/php

sudo apt-get update

Now try this command

sudo aptitude install php7.2-curl

Aptitude will ask you you want to keep current version of all dependencies

The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     php7.2-curl [Not Installed]                        



Accept this solution? [Y/n/q/?]

Type n then Enter

Aptitude will find all dependencies and ask you to install all package type

y

Again

y

Then

systemctl restart apache2

For centos of rhel

systemctl restart httpd

It will Not enabling PHP 7.2 FPM by default. NOTICE: To enable PHP 7.2 FPM in Apache2 do

a2enmod proxy_fcgi setenvif

a2enconf php7.2-fpm

This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.

Upvote if you find your solution
Ronny Dsouza
  • 358
  • 2
  • 12
  • Please do not post the same answer multiple times without checking whether it matches the given question. `sudo apt-add-repository ppa:ondrej/php` does not add any package, and this won't even work when using WAMP on Windows 8 with an already enabled cURL extension – Nico Haase Oct 31 '21 at 06:53