2017-05-25 52 views
1

我想用蒙戈DB與PHP的,所以我已經安裝了驅動程序和顯示,以及在phpinfo() enter image description here蒙戈DB PHP驅動程序致命錯誤

問題是,當我嘗試連接在這裏,我得到致命錯誤。

Fatal error: Uncaught Error: Class 'MongoDB\Client' not found

這裏是我如何連接

$mongo = new \MongoDB\Client('mongodb://user:[email protected]/chat'); 
    try 
    { 
     $dbs = $mongo->listDatabases(); 
     print_r($dbs); 
    } 

這裏是我安裝的擴展sudo apt-get install php7.0-mongodb 我也遵循了這一http://php.net/manual/en/mongodb.tutorial.library.php 任何幫助!

+0

我跟着這個http://php.net/manual/en/mongodb.tutorial.library.php –

+0

請編輯問題,而不是評論它。還要添加您用來安裝擴展的命令。 'MongoDB \ Client'來自現在已過時的舊版庫。 –

+0

完成後,我編輯了我的問題... –

回答

-1

\MongoDB\Client屬於mongo-php-library這是從另一個詞mongo-php-driver

不同,該庫使用的驅動程序,

所以安裝蒙戈的PHP驅動程序後,您需要通過安裝來執行其他操作庫使用作曲家

composer require mongodb/mongodb 

或甚至通過從GitHub

0克隆它
0

你可以用php和mongoDB來檢查這個覆蓋所有CRUD操作的項目,並給出了關於php和mongoDB設置的一些指導。 php mongoDB CRUD operations