2017-03-16 19 views
1

我是mongoDB的初學者,我想學習mongoDB。所以我讀了幾個教程,並試圖在我的本地機器上配置mongoDB,因爲我已經下載了mondoDB的php_mongo.dll文件,並將它放在我的本地機器中,放到路徑「php/ext/php_mongo.dll」中,之後我添加了這個代碼「延長= php_mongo.dll」爲php.ini文件,在那之後我試圖運行我的XAMPP服務器,但立即它顯示下面的錯誤:如何用php XAMPP設置mongodb?

C:xampp\php\ext\php_mongo.dll is either not designed to run on Windows 
or it contains an error. Try installing the program again using the 
original installation media or contact your system administrator or 
the software vendor for support. 

,不知怎的,Apache服務器開始之後當我嘗試通過URL http://localhost/mongoapp/index.php瀏覽器上運行應用程序則拋出以下錯誤:

Fatal error: Uncaught Error: Class 'MongoClient' not found in C:\xampp\htdocs\mongoapp\index.php:3 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mongoapp\index.php on line 3 

文件:index.php文件

// connect to mongodb 
$m = new MongoClient(); 
echo "Connection to database successfully"; 
// select a database 
$db = $m->mydb; 
echo "Database mydb selected"; 

我的PHP版本是「PHP版本7.0.8」。希望有人幫助,提前致謝。

回答