简体   繁体   中英

MongoClient not found in PHP

I have downloaded php_mongo-1.3.2RC1.zip from https://github.com/mongodb/mongo-php-driver/downloads Then I have extracted all of them in my C:\\xampp\\php\\ext directory. To use mongodb though php file located in 'C:\\xampp\\htdocs\\index.php' directory, I have added extension=php_mongo-1.3.2RC1-5.2-vc9.dll this line to C:\\xampp\\php\\php.ini .

Yet I have got this error Fatal error: Class 'MongoClient' not found . What can I do to make it work?

I am using Xampp on windows 8 64 bit running on php 5.2 .

I have tried writing php on cmd and it returns this following lines:

Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20100525
These options need to match
 in Unknown on line 0

I have tried phpinfo() as @j0k has asked, and it returned:

Configuration File (php.ini) Path   C:\Windows
Loaded Configuration File   C:\xampp\php\php.ini

尝试这个:

pear install -f pecl/mongo

I think you use php 5.4 (info from my web server):

$ php -v; phpize -v
PHP 5.4.11 (cli) (built: Feb 10 2013 03:38:26) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

API module versions are identical.

…
Module compiled with module API=20060613
…

It is php 5.2 (from source code):

$ grep '#define ZEND_MODULE_API_NO' php-src-php-5.2.17/Zend/zend_modules.h| sed 's/#define ZEND_MODULE_API_NO//'
 20060613

Check you version php ( php -v; phpize -v ) and setup php-mongo-driver. You can see versions in phpinfo(); ( recommended ; PHP API, PHP Extension, Zend Extension, Thread Safety)

Try to restart your Apache. Apache will not try to reload the configuration upon edit. For xampp you can do this in the cornor pressing shutdown or restart, if I Remember correctly. Alternative you can restart your pc

From this page:

Note: Additional DLL dependencies for Windows Users:

In order for this extension to work, there are DLL files that must be available to the Windows system PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM