8

I would to connect lampp to mongodb so I need to install mongodb client , I do sudo pecl install mongo il m'affiche le message suivant :

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mongo.so' - /usr/lib/php/20151012/mongo.so: undefined symbol: zval_used_for_init in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mongo.dll' - /usr/lib/php/20151012/php_mongo.dll: cannot open shared object file: No such file or directory in Unknown on line 0 WARNING: "pecl/mongo" is deprecated in favor of "channel:///mongodb" pecl/mongo requires PHP (version >= 5.3.0, version <= 5.99.99), installed version is 7.0.4-7ubuntu2.1 No valid packages found install failed, please how to correct this error

Hassaan
  • 6,355
  • 5
  • 25
  • 44
Sarah
  • 119
  • 1
  • 9

2 Answers2

13

mongo is the old driver which is not compatible with PHP 7, you need to use new driver mongodb.

malarzm
  • 2,641
  • 2
  • 14
  • 21
  • 1
    Thinks, can you tell me how I use the new driver mongodb – Sarah Jun 26 '16 at 16:06
  • Thinks I do under the folder /opt/lampp/bin : sudo pecl install mongodb, and it works :) – Sarah Jun 27 '16 at 11:57
  • Now, I try to test connection xampp with database mongodb, so I create a file sample.php which contains this code : Connection to database successfully"; $m=new MongoClient(); echo "

    Connection to database successfully

    "; $db=$m -> loginproject; echo "

    database $db successfully

    "; ?>
    – Sarah Jun 27 '16 at 12:00
  • when I run localhost/sample.php I find this error: Fatal error: Class 'MongoClient' not found in /opt/lampp/htdocs/sample.php on line 3; please help me to correct this error – Sarah Jun 27 '16 at 12:05
  • Have you read the docs I linked? `MongoClient` is from OLD driver and it's not available in new one – malarzm Jun 27 '16 at 14:06
  • Example of usage `pecl install -f mongodb-stable` from https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/.travis.yml – Daniel May 23 '19 at 22:48
2

It's easy all you have to do is change it to sudo pecl install mongodb

Nimr Sawafta
  • 173
  • 7