I try to install mongo in my PC (windows 7). I have wamp 2.2.11 with php 5.3.0
I follow the instruction from.
http://php.net/manual/en/mongo.installation.php#mongo.installation.windows
But it is not working with the code
$m = new MongoClient();
echo "Connection to database successfully";
Giving Fatal error: Class 'MongoClient' not found.
I have search here
MongoClient not found in WAMP
MongoDB not working with PHP on WAMP
WAMPServer Fatal error: Class 'Mongo' not found
And some other but nothing happen. I have add php_mongo.dll file at
wamp\bin\php\php5.3.0\ext
And change php.ini at wamp\bin\apache\Apache2.2.11\bin
But it is not working.
Please help.
Related
I install mongodb on xampp . It show successfully installed in phpinfo. But when I call it says me this error
Fatal error: Uncaught Error: Class 'MongoClient' not found in ...
my code :
echo extension_loaded('mongodb');
$mongo = new MongoClient("mongodb://localhost:27017");
I install it manually. First line echo true.
MongoClient seems to be part of mongo extension. You are checking for mongodb extension which wouldn't define it.
Here are some necessary version related details of the packages I have installed on a dream-compute (godaddy) server machine with Ubuntu 16.04 with root access
Apache Server version: Apache/2.4.18 (Ubuntu)
php version 7
mongo db version v3.2.10 and
$ pecl search mongo
.Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest) Local
mongo 1.6.14 (stable) MongoDB database driver
mongodb 1.1.9 (stable) 1.1.9 MongoDB driver for PHP
I have set up a website that was previously running on a different server with PHP 5.6 and an old mongo-php driver.
Previously I was using MongoClient class in the connection string but after some searching I changed it to MongoDB\Driver\Manager in my connection class of the php website.
I have also included extension=mongodb.so in the /etc/php/7.0/apache2/php.ini file
The rest of the website is working fine, only when i browse to a page which has a mongodb call at the back-end gives me the following error (from php error log file):
PHP Warning: Module 'mongodb' already loaded in Unknown on line 0
PHP Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Manager::selectDB() in /var/www/html/iot/includes/class.abstract-data-collection.php:118
I am not an expert in linux and hence I am stuck here. Anyone have any idea what should I try to actually get to the problem, should I need to change the php code or is there anything I am missing in the configuration?
TA
I want to connect to MongoDB from PHP but I keep getting the fatal error in the title. My PHP version is 5.5.14, architecture x86, thread safety enabled, VC11.
So I downloaded 5.5 Thread Safe (TS) x86 from PECL, extracted php_mongo.dll to the \ext\ folder of my php installation, added extension=php_mongo.dll to the php.ini file, and restarted Apache.
I keep getting the same fatal error when I use either Mongo() and MongoClient().
Also, I can access mongo from CMD, starting it with mongod and then opening another cmd window to handle the database using mongo. I installed PHP and Apache separately (No XAMPP or WAMP) on Windows 8.1 x64.
Installation folders:
Apache: C:\Apache24
PHP: C:\php
MongoDB: C:\Program Files\MongoDB
In the lastest version, you can use new MongoDB\Driver\Manager() to create the obj instead of the MongoClient().
I am trying to install MongoDb on windows platform. I'm using PHP with WampServer.
But while executing the PHP program it gives the following error:
Fatal error: Class 'Mongo' not found in C:\wamp\www\test\index.php on line 19
So is there any way to check whether MongoDB is running with PHP or not ?
Please check php loaded extensions using phpinfo() function whether mongoDB extension is loaded or not.
Do check these as well.
Fatal Error - 'Mongo' class not found
Fatal error: Class 'Mongo' not found in xampp
Add the following line to your php.ini file:
extension=php_mongo.dll
Docs Link: http://php.net/manual/en/mongo.installation.php
Check this possible solution
Copy c:\wamp\bin\php\php-5.3.x\ext\
Edit c:\wamp\bin\apache\Apache2.2.xx\bin\php.ini and add the line where the extensions are loaded.
Why run WAMP on 32bit Windows 7 64bit?
The Mongo PHP driver does not have a 64bit binary win32, if you are running the 64bit version of WAMP, PHP will refuse to load the 32-bit version of php_mongo.dll.
Fatal error:
Class 'Mongo' not found in C:\Apache
Software
Foundation\Apache2.2\htdocs\sample\testdb.php
Can anyone help me out with this issue? Why is that saying so?
The following is the code that I have used. I have created a database named phptest in MongoDB and inserted a document. Then I tried connecting to MongoDB via PHP but it threw this error.
Can anyone help me get rid of this? I have included the php-mongo dll and saved in php.ini file also.
<?php
echo "succeeded!";
$connection = new Mongo();
$db = $connection->test;
$collection = $db->phptest;
?>
Make sure you have the correct php driver installed.
For example if "Thread Safety" is enabled in your php.ini, then make sure you have the "Thread-Safe Mongo Extension" installed and NOT the "Non-Thread-Safe" version.
You're probably using an older version of the Mongo DB driver. The class Mongo has been replaced with MongoClient, since v 1.3.0 of the driver. See this stackoverflow thread :
mongo DB - php driver version
http://www.php.net/manual/en/class.mongo.php