I'm probably doing something silly here but I've been trying to install the mongodb php client on my windows VM running WAMP for a while and I've gotten nowhere.
I'm running WAMP 64 bit with PHP 5.4.3. I downloaded the 1.3.2RC1 zip from here and I extracted the php_mongo-1.3.2RC1-5.4-vc9.dll file into wamp/bin/php/php5.4.3/ext and then edited the php.ini file to include the new extension.
I restart WAMP and everything is fine, then when I try and use some of the code from the php mongo driver tutorial it says the MongoClient class cannot be found:
Fatal error: Class 'MongoClient' not found in C:\wamp\www\mongo\test.php ...
The code is simple but for completeness I'll include it:
<?php
$m = new MongoClient("the-connection-string-im-using");
?>
Am I missing something? Should I just be able to create a new instance of the MongoClient like above or do I need to do something else?
Cheers
James
I figured it out - I was using the wrong php.ini file. I should have been using the one in the apache directory (C:\wamp\bin\apache\apache2.2.22\bin).
Silly.
Related
I installed the MongoDB PHP driver on Windows 10 (I'm using WAMP equipped with PHP 5.6.25. following the istructions I found at http://php.net/manual/en/mongodb.installation.windows.php and I installed also the libbson and libmongoc libraries (requested as requirements) as written at http://php.net/manual/en/mongodb.requirements.php.
Then, I added the bin folders of MongoDB, libbson and libmongoc to system path.
However, even if I can see the php_mongodb extension in the extensions list of WAMP, launching phpinfo() the mongo extension doesn't appear with the others.
Furthermore, tryng to connect to my database with
<?php
$mongo=new MongoClient("");
$db=$mongo->galileo;
$collection= $db->items;
print_r("Number of documens: "); ?>
I got the error
Fatal error: Class 'MongoClient' not found in C:\wamp64\www\galileo\index.php >on line 21
At a first look, reading this error, it might seem like that PHP is looking for php_mongodb extension in the uncorrect folder i.e. C:\wamp64\www\galileo\index.php (where the index page of my project is placed) instead of the correct one C:\wamp64\bin\php\php5.6.25\ext where all the extensions are.
But, looking at php log file php_error.log I find also a warning that says:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php5.6.25/ext/php_mongodb.dll' - Il sistema operativo non pu� eseguire %1.
in Unknown on line 0.
(for not Italian speaking, the phrase after - means the operating system can't execute %1, even if I can't imagine what %1 stands for).
Even using the new class MongoDB\Driver\Manager I get the error
Fatal error: Class 'MongoDB\Driver\Manager' not found in C:\wamp64\www\galileo\index.php on line 21
and the same warning.
Do you notice some error or forgetfulness in the installation process as I described and, if not, do you know how to fix the problem?
The problem is certainly related to WAMP and I think is related to the multiple php.ini in his folders. In fact, in the apache folder you can find a php.ini file that cannot be modified, otherwise nothing works at all; at the same time any changes made to the php.ini file in the php folder seems have no effect except making appear the mongodb extension in the extensions list.
So, I try using XAMPP, as suggested in this video tutorial and it works. Using Composer I was able to install also the PHP library and not only the driver.
you should not use 'MongoClient class' anymore, this extension that defines this class is deprecated. look at here.
instead, you should use MongoDB\Driver\Manager class. please read http://php.net/manual/en/class.mongodb-driver-manager.php.
and the setup must be like this in php:
$mongo = new MongoDB\Driver\Manager("mongodb://localhost:27017");
And if you still use the old class; you either need to install the old legacy extension (pecl install mongo) and use PHP 5.x, or update your code to use this new driver's classes as the old driver is not available for PHP 7. There is an upgrade guide at here.
the last part is from derickr's answer in this issue on github: https://github.com/mongodb/mongo-php-driver/issues/300
I have few controllers in my zf2 project which work perfectly in the browser using apache and via command line.
However, I recently installed MongoDb so I can store some data using the driver found in (http://php.net/manual/en/set.mongodb.php)
My issue is, when I try to access the driver via controller + browser, I get the following message error in my apache logs :
PHP Fatal error: Class 'MongoDb\Driver\Manager' not found.
'MongoDb\Driver\Manager' is the namespace for this Driver.
If I execute some other controllers via command line, MongoDb works correctly.
Does anyone know why is this happening? I cannot see the issue :(
Thank you
I found that my php.ini was pointing to mongo.so instead of mongodb.so
That fixed the issue
http://php.net/manual/en/mongodb.installation.manual.php
Thank you for your help
I attempting to setup Phalcon PHP using a Mongo database connection. I have configured my bootstrap (index.php) file using the following:
// Mongo database connection
$di->set('mongo', function(){
$mongo = new Mongo();
return $mongo->selectDb("phalcon");
}, true);
// Collection Manager
$di->set('collectionManager', function(){
return new \Phalcon\Mvc\Collection\Manager();
});
Whenever I attempt execute an insert fucntion in using this connection, I receive a 500 Internal server error. Now, I have checked my apache server error logs and it states "PHP Fatal error: Class 'Mongo' not found in /var/www/phalcon-mongo/public/index.php on line 17".
I don't know why this request is not processing, according to the documentation given from Phalcon, the connection to mongo DB is setup up as I have displayed above.
If anyone has any advice, please let me know.
i think it's because your installation of Mongo is not valid.
try printing phpinfo() and check if mongo is loaded at all, if not - install it, add to ini files (if you use cli, don't forget to add to cli ini too) and reach the moment, when mongo is fully loaded.
try mongo w/o phalcon. any simple connection/insertation. you can see here: Fatal Error - 'Mongo' class not found that there are problems with apache module version for some people. Try reinstalling different mongo version.
if you can print this out:
echo Phalcon\Version::get();
there should be no problems with phalcon instalation
to validate mongo installation, try any of examples from php.net:
http://www.php.net/manual/en/mongo.tutorial.php
if both installations are valid, then there are problems with your custom code, but before doing anything you have to validate both installations.
There already is a working WAMP instance in a Windows 7 in which the line
$x = new COM("X");
does instantiate a COM object.
I was trying to locate a bug, and decided to use a fresh new WAMP installation on the same Windows 7 system as the previous one.
In the new one, the same line produces:
Failed to create COM object 'X': Class not registered ( Error code: 0x80040154 )
Now, since the first WAMP comes with it's own installation application (along with its DLL which holds the COM class) I can't exactly figure out what I need to change in the new WAMP so the line above will instantiate the object.
My WAMP version is: 2.2 and
Apache version : 2.2.21
PHP version : 5.3.10
Any idea what I need to set up properly?
You need to register the DLL, using
regsvr32 yourdll.dll
Managed to solve the problem by changing the working directory (using chdir) to be the same as the php.exe just before $x = new COM("X");.
I think the DLL wasn't propery registered, or lacked something in itself.
I'm trying to use the informix pdo driver but I always get the following error:
"could not find driver"
I'm using the Microsoft IIS with PHPManager and PHP version 5.3.5. The php_pdo_informix.dll is located in the correct folder and enabled in the php.ini
Are there any ideas where the problem lies?
I don't use PHP nor pdo drivers, but you can use Process Monitor by SysInternals/Microsoft to see if php_pdo_informix.dll is loaded.
Often Informix drivers do not load, because some environment variables are not set. Especially INFORMIX_DIR, CLIENT_LOCALE, DB_LOCALE, SERVER_LOCALE, DBLANG. Do you have Informix Client installed? Are you able to set up and test ODBC connection?
You can also add directory with php_pdo_informix.dll to PATH.
EDIT:
I downloaded php_pdo_informix.dll and it seems that this file is broken. I tested it with my Python utility to check dll libraries: http://code.activestate.com/recipes/576522-searching-dll-and-exe-files-in-path/
c:\download>which_dll.py php_pdo_informix.dll
2011-03-04 08:03:45 32833 [b] c:\download\php_pdo_informix.dll
ver:5.2.5.5
trying to load "php_pdo_informix.dll" ...
Cannot load "php_pdo_informix.dll" !!!
And MessageBox appeared (translation from Polish)
---------------------------
python.exe - Bad image file
---------------------------
Aplication or libarary DLL c:\download\php_pdo_informix.dll is not correct image of Windowns NT. Check it with install disc.
---------------------------
OK
---------------------------
SHA1 sum of library I downloaded:
b38bc54839c7c4b82e2057763ef1c6584dcbbb1f *php_pdo_informix.dll
If your PHP is VC9, try this:
php_pdo_informix_PHP5.3_VC9.zip
I had this problem, and I solved by installing the CSDK from IBM to get the php_pdo_informix.dll to work, you can download it from http://www14.software.ibm.com/webapp/download/search.jsp?rs=ifxdl