sadaf2605
sadaf2605

Reputation: 7550

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

Upvotes: 3

Views: 17688

Answers (4)

M D P
M D P

Reputation: 4650

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

Upvotes: 0

user3058157
user3058157

Reputation: 143

Try this:

pear install -f pecl/mongo

Upvotes: 6

Smarties89
Smarties89

Reputation: 561

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

Upvotes: 1

Vladimir Korshunov
Vladimir Korshunov

Reputation: 3090

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)

Upvotes: 1

Related Questions