Question

Error with PECL command in PHP7

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

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

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

Enjoy!

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”

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