I am trying to setup mongodb + php mongo driver using homebrew
I am trying to setup a composer package which requires mongodb.
The extension seems to be installed, as it appear in both cli and web version as below. But when I hit the webroot I get the error
Fatal error: Class 'MongoClient' not found in
/Users/sakhunzai/Sites/xhgui/public/src/Xhgui/ServiceContainer.php on
line 77
I am able to connect to mongodb and create a database etc. So mongodb is running fine. But It seems there is issue with php extension. To setup xhgui I have brewed as follow:
brew tap tideways/homebrew-profiler
brew install php56-tideways
brew install mongodb php56-mongodb
MongoDB
mongo --version
MongoDB shell version: 3.2.4
Extension
php -i|grep mongo
/usr/local/etc/php/5.6/conf.d/ext-mongodb.ini,
mongodb
mongodb support => enabled
mongodb version => 1.1.6
mongodb stability => stable
libmongoc version => 1.3.5
mongodb.debug => no value => no value
cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
There are two kinds of drivers available at pecl
you need to install the mongoDB database driver to access mongoClient
use the following command to install the mongo
brew install php56-mongo
as explained here
You will get something like this in your phpinfo();
I hope this helps. Thanks,
Related
We're using a MSSQL db at work and I want to be able to write PHP scripts that fetches data directly from the db to my local MAMP environment. I've tried installing pdo_sqlsrv and sqlsrv using Homebrew and I've tried compiling the extensions on my own using PECL commands, but in both cases it has ended unsuccessfully with the error message:
fatal error: 'sql.h' file not found
I've been googling this problem all day and can't seem to find a solution that I can get to work/understand. I'd be grateful for any help or hints.
Computer: Macbook Pro 2018 (macOS 10.13.6)
Local environment: MAMP PRO 4.5 (PHP version: 7.2.1)
I found the solution here: https://github.com/Microsoft/msphpsql/issues/198
I was missing tools provided by unixodbc, so:
brew install unixodbc
...provided the .h file(s) I was missing. The PECL installer was then able to locate the required libraries. In case it wouldn't have worked, I would have tried:
sudo CXXFLAGS="-I/usr/local/opt/unixodbc/include" LDFLAGS="-L/usr/local/lib" pecl install pdo_sqlsrv
sudo CXXFLAGS="-I/usr/local/opt/unixodbc/include" LDFLAGS="-L/usr/local/lib" pecl install sqlsrv
...as suggested in the link.
Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionException: Server at localhost:27017 reports wire version 0, but this version of libmongoc requires at least 3 (MongoDB 3.0)
I have PHP 7.0.13, MAMP and MongoDB. The MongoDB extension for PHP has been installed.
I have the following:
<?php
ini_set('display_errors', 'On');
require 'vendor/autoload.php';
var_dump(extension_loaded('mongodb'));
echo phpversion('mongodb')."\n";
$m = new MongoDB\Driver\Manager("mongodb://localhost:27017");
// Query Class
$query = new MongoDB\Driver\Query(array('age' => 30));
// Output of the executeQuery will be object of MongoDB\Driver\Cursor class
$cursor = $m->executeQuery('testDb.testColl', $query);
// Convert cursor to Array and print result
print_r($cursor->toArray());
?>
What does 'wire' refer to in this context, and does anyone have a solution for this problem?
I have got the problem on Linux Mint 19 (think that Ubuntu 18+ can have the same problem):
Server at IP:27017 reports wire version 2, but this version of libmongoc requires at least 3 (MongoDB 3.0)
As the message says - server driver version and mine one are different.
This happened because I installed php mongo driver with the command:
sudo apt-get install php7.2-mongodb
The SOLUTION was to completely uninstall php mongo driver:
sudo apt-get remove --auto-remove php-mongodb
and then install php-mongodb from Pecl mongodb php extension:
sudo pecl install mongodb-1.4.4
(If you bump into error pecl: command not found, just install PEAR package in order to use pecl installer. sudo apt-get update && sudo apt-get install php-pear)
After that add the next line to your php.ini file:
extension=mongodb.so
Don't forget to reload the web server:
sudo systemctl reload apache2
That's it. Everything should work!
If anyone searching for solution for Centos 7, here's what you need to do (based on Evgeny Melnikov answer):
yum erase php-pecl-mongodb && pecl uninstall mongodb
pecl install mongodb-1.9.1
Then add extension=mongodb.so to your php.ini file and restart php-fpm.
I have a Raspberry Pi 3B with mongo version. It runs an older version of MongoDB, so I found an equally old version of pymongo and it worked.
mongo --version
MongoDB shell version: 2.4.14
min_wire_version was added sometime after the release of Mongo 2.4.14, so I just installed pymongo drivers that were equally as old.
pip install pymongo==2.4.2 worked for me.
https://pecl.php.net/package-info.php?package=mongodb&version=1.13.0
pecl uninstall mongodb
pecl install mongodb-1.13.0
I am attempting to install Learning Locker on an Amazon Linux site on AWS. I have been following the step-by-step directions on this site, which has been helpful till now. Unfortunately now I am stuck.
Learning Locker requires the older version of the Mongo driver (mongo.so) for PHP. I think this is the latest version. However if I try to install the driver using pecl it will either install the new version of the driver (mongodb.so) or if I specific "pecl install mongo" I get an error that this version is depreciated.
At this point I need to:
Uninstall the mongodb.so driver that is installed currently.
Install the legacy mongo.so driver.
I have searched the Internet but I have not found what I need to know how to uninstall the existing driver and install the legacy driver.
Suggestions? Any insight will be appreciated. Thanks!!!
With more research I was able to learn how to install an older driver with pecl.
pecl search mongo
Retrieving data...0%
.Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest) Local
mongo 1.6.14 (stable) 1.6.14 MongoDB database driver
mongodb 1.2.8 (stable) 1.2.7 MongoDB driver for PHP
sudo pecl install mongo-1.6.14
This worked and I was able to run Composer to install Learning Locker.
I still need to uninstall mongodb.so but that is a work in progress.
I have added mongodb.so in both /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini as shown below
extension=/usr/lib/php5/20100525/mongodb.so
But still I am getting the below error Class 'MongoDate' not found.
Php Version - Php 5.4.45
Below is the information about mongodb extension from php cli
php -i | grep -i mongodb
mongodb
MongoDB support => enabled
MongoDB extension version => 1.2.5
MongoDB extension stability => stable
mongodb.debug => no value => no value
Below is the output of phpinfo() for php running under apache2
Can someone let me know how can I get rid of this error?
mongo is old driver, mongodb is new driver, and mongo has been superseded, see https://pecl.php.net/package/mongo
mongodb (new): https://pecl.php.net/package/mongodb
The class MongoDate is mongo's class. In mongodb, you should be use MongoDB\BSON\UTCDateTime to replace MongoDate, see http://php.net/manual/en/class.mongodb-bson-utcdatetime.php
If you want to keep use class MongoDate, you can use pecl or manually to install old driver.
I installed php53 on mac osx with homebrew. I need to enable pdo driver for firebird.
I tried to instal via pecl ..
I donwload http://pecl.php.net/package/PDO_FIREBIRD
and compile this but I get this error
...
...
configure: error: libgds or libib_util not found! Check config.log for more information.
I found that means that I don't have installed firebird develepoment libraries...
I have installed firebird 2.0 on my mac.. this version is working Flamerobin.
Does anyone have pdo firebird driver on mac server installed via homebrew?
Pdo Firebird from pecl is deprecated , i will updated it soon that i get access to it
you need to download the source code for php extract it and then build only the pdo_firebird extension
cd ext/pdo_firebird
phpize
./configure
(you might need to pass the firebird framework dir --with-pdo-firebird=/Library/Frameworks/Firebird.framework )
make
sudo make install
after that you need to copy the extension in your brew build php extensions folder and add it to php.ini
extension=pdo_firebird.so
I also recommend firebird 2.5.x is more recent and well supported on recent macosx versions
I've solve this issue by :
sudo ln -s /Library/Frameworks/Firebird.framework/Versions/A/Firebird /usr/local/lib/libfbclient.dylib
macOS High Siera 10.13.3