Amit S
Amit S

Reputation: 36

mongo db not working with xampp or php(mongo insatalation not working with xampp)

I am trying to use mongo db database so I try to install the mongo db and I done with installation part.Now I have to work with php so I followed the steps mention on mongodb site and php manual also I placed the dll file in php/ext folder and made changes in php.ini file i.e. I put "extension=php_mongo.dll" as explained in documentations and also I restarted the web server but it still not working.My phpinfo not showing support for mongo also "MongoClient" class not found. I checked the versions of php and driver everything is correct still I canot use the mongo.

Any help will highly appreciated. Thanks.

Upvotes: 0

Views: 2985

Answers (2)

Balaji Mitkari
Balaji Mitkari

Reputation: 80

After you place the correct .dll file in to the ..php/ext folder, In order for this extension to work, there are DLL files that must be available to the Windows system PATH. You can try that by adding your PHP directory to the PATH on Windows.

Follow below steps and check if it works :

  • Stop apache server in xampp control panel.
  • Go to Control Panel and open the System icon (Start → Control Panel)
  • Go to the Advanced tab
  • Click on the 'Environment Variables' button
  • Look into the 'System Variables' pane
  • Find the Path entry (you may need to scroll to find it)
  • Double click on the Path entry
  • Enter your PHP directory at the end, including ';' before (e.g. ;C:\xampp\php)
  • Press OK
  • Start apache server in xampp control panel.
  • Now go to the directory where you installed MongoDb and command prompt
  • Go to /bin directory inside the Mongo installation folder and run the command "mongod --dbpath " (e.g. mongod --dbpath C:\xampp\htdocs\mongo-demo\db ) and keep it running
  • Now open new command prompt in the same directory and run mongo command to start mongo

Now try running the below php code in in localhost/"path to your .php file" (e.g. C:\xampp\htdocs\mongo-demo\demo.php) and check if it runs without any error:

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

Upvotes: 1

jmikola
jmikola

Reputation: 6922

Since GitHub no longer allows repositories to host binaries, Windows releases of the PHP driver are now hosted on S3, with links provided in the release announcement threads on the mongodb-announce mailing list. The most recent release (at the time of this writing) is 1.3.6, which you can find in this thread.

I would definitely recommend upgrading your driver, as the version you cited above is only a release candidate. Once you have the most recent driver, either of the following threads should be helpful on getting up and running with XAMPP:

Upvotes: 0

Related Questions