Error with PECL command in PHP7

March 3, 2016 21.4k views
Ubuntu PHP

I’ve upgraded php to version 7 and now I have problems with pecl command. When I run sudo pecl install mongo I get long list of errors:

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

I’ve tried solutions from this question: https://serverfault.com/questions/589877/pecl-command-produces-long-list-of-errors but it’s not working. I’m using Ubuntu 14.04 with PHP7, I installed php-dev package

2 comments
4 Answers

Hey there,

It looks like the ‘mongo’ package has been depreciated with PHP 7. You might have better luck with the following:

pecl install mongodb

For more information you should take a look at the following resources:

https://docs.mongodb.org/ecosystem/drivers/php/
http://stackoverflow.com/questions/34486808/installing-the-php-7-mongodb-client-driver

Regards,
Mike C
Platform Support Specialist
DigitalOcean Support

  • A quick glance at the OP would show you that the problem has nothing to do with the particular extension they’re trying to install, but it’s pecl that is broken itself.
    So “pecl install mongodb” will produce exactly the same errors and doesn’t solve the issue at all.

Hello,

to fix this error at me helps:
sudo apt-get install php-xml php7.0-xml

Enjoy!

i have this problem too
i have php 5.6 and some php 7.1 lib on ubonto 16
so after a lot of search i found that i need to install this list –> and after its works!!

so i installed

apt-get install php-pear

apt-get install pkg-config

apt-get install libbson-1.0

apt-get install libmongoc-1.0-0

apt-get install php-xml php7.0-xml

apt-get install php-dev

then Add the following line to your php.ini file:

extension=mongodb.so

some more information
for php 7.1 you must use the “mongodb” extension
for php 5.6 you need to use “mongo” (dont sure if it must - but i didnt success to use mongodb in php 5.6 )

so for php 5.6 use “apt-get php5.6-mongo”

Have another answer? Share your knowledge.