i try to install MongoDB and Mongo PHP Driver for 5.6.x for MAMP PRO , but i finishing installation (also i add extension on php.ini) but still doesn't work. Any one help me ?
it would be useful if you could give more information about versions (MAMPP version, MongoDB server version, Mongo driver version...).
However the most common problem with Mongo and php is that there are two different drivers, both can be installed through PECL.
mongo-php : Legacy driver, not recommended anymore.
sudo pecl install mongo
Add to php.ini -> extension=mongo.so
mongodb-php : New driver, recommended.
sudo pecl install mongodb
Add to php.ini -> extension=mongodb.so
While mongo-driver works with PHP versions < 7.0 mongodb driver works with PHP versions > 5.5. But some libraries are still using old mongo driver (i.e.doctrine) and could need an adapter if you want to work with the new driver.
Old driver repo: https://github.com/mongodb/mongo-php-driver-legacy
New driver repo: https://github.com/mongodb/mongo-php-library
To be sure which driver is working in your system, you can perform this easy test. Create two PHP scripts with the following initialization:
If this works then you have old driver installed
$connection = new MongoClient({here your conn data})
If this works then you have the new driver installed
$connection = new MongoDB\Driver\Manager({here your conn data})
Hope this will be useful for any user with the same problem on any platform.
(Please note the extension for windows user will be .dll instead of .so)
Related
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'm trying to install Yii2 mongo extension, I have already installed the mongo php driver and it showing in phpinfo. Please refer the screenshot for error. I have tried with both mongo and mongodb drivers, none are working.
I have tried the composer command
composer require "mongodb/mongodb=^1.0.0
from
http://us1.php.net/manual/en/mongodb.tutorial.library.php
its still the same output.
Check if there is a second php.ini for CLI version - probably mongodb is not added there (or just commented out). php --ini in console should help you find it. Fix configuration, restart apache and it should be fine.
Mongo driver is deprecated, in place of that mongodb drivers are added for newer version of PHP. Try installing Mongodb driver.
Steps for installation
http://php.net/manual/en/set.mongodb.php
Try with Xamp, I had issue with wamp and mongodb in windows.
refer this link for procedure.
I have a server with this configuration:
centos 6.4
PHP 5.4
SQLite Library 3.6.20 (this is from phpinfo())
I desperately need to upgrade the sqlite library. I need to access from php a sqlite library. It seems that that database was created with sqlite 3.7. When I try to open it from php, I get this error "file is encrypted or is not a database". Updating that driver will solve the problem
Php was installed with the command yum --enablerepo=remi install php-fpm
I have found some answers like yum install php5-sqlite, it seems that this is an old command. Usually I find some outdated answers. I would need something to work with php 5.4. Installing with pecl did not work either.
Please help
I have no issue reading a sqliteDB generated with SQLite 3.8 (Fedora) from an CentOS 6 box with SQLite 3.6
php -r 'var_dump(
$db=new sqlite3("/tmp/test.sqlite"),
$q=$db->query("SELECT name FROM sqlite_master"));
foreach ($q->fetchArray() as $r) var_dump($r);'
With PDO:
php -r 'var_dump(
$db=new PDO("sqlite:/tmp/test.sqlite"),
$q=$db->query("SELECT * FROM sqlite_master"),
$q->fetchAll()); '
Of course, you need to use "sqlite3" or "pdo_sqlite" extension, not the old deprecated "sqlite" one.
Today some of my packages in Ubuntu was upgraded automatically, and I didn't think of what was actually going on.
Ever since the update, my local dev-environment doesn't work anymore. First of by not working was mod_rewrite which I had to enable again using a2enmod. But now I've run into an issue that I can't seem to resolve. My application can't seem to find the PDO MySQL driver. When running the application, I get the error failed to open the DB connection: could not find driver.
This is strange, since if I check the phpinfo() the PDO drivers do support MySQL, and the socket path is a valid path.
pdo_mysql client API version is 5.5.35 according to php info.
PHP5: 5.5.3
MySQL: 5.5.35
Connectionstring
mysql:host=127.0.0.1;dbname=MyDB;port=3306
What could be causing this?
The PHP MySQL driver (mysql.so/mysqli.so) and the PHP PDO MySQL driver (pdo_mysql.so) are two separate modules. You need both of them for PDO functionality with MySQL.
It is quite possible that one of them is missing or of an incompatible version - I do not have an Ubuntu system at hand, but on my RPM-based Linux distribution there is a separate package for each module (php-mysql/php-mysqli and php-pdo_mysql). I also expect PDO to be using the newer mysqli.so driver, rather than the obsolete mysql.so one, so you should verify that one is installed as well.
Try this:
sudo apt-get install -y php5-mysql php5 mysql-client
This should automatically restart your apache if any of the dependencies aren't installed.
Try using vagrant.
Dependencies can be isolated, upgraded and downgraded when you like.
Vagrant
I'm trying to install mongodb in a PHP environment. MongoDB itself is installed fine, I've run pecl install mongo, and added extension=mongo.so to php.ini; but my Laravel application complains that it can't find the class MongoClient. Checking phpinfo() reveals no mention of Mongo, suggesting that it isn't aware of the driver.
I noticed that all the instructions for installing mongo on Ubuntu mention apt-get install php5-dev. Is that a requirement for the mongodb php driver? At the moment the server is built with Chef and installs php with apache2::mod_php5. If php5-dev is required, can it be installed as an apache module?
Yeah you should as stated by docs here http://docs.mongodb.org/ecosystem/drivers/php/
Also if its unable to find mongo drivers ,Try debugging , check logs if it says something like mongo.so file is missing.
Don't forget to restart php and apache after saving php.ini