Update/Upgrade PHP MongoDB driver - php

Im currently running Php MongoDb version 1.2.10 and I'm wanting to update this version to the most recent/stable.
How would one go about doing this? Im assuming it would be via terminal and using pear or pecl command?
Any Help or advice is greatly appreciated :)
Update :
I did the following within terminal to install the latest version
sudo pecl install mongo
Which has installed version 1.5.6. But after restarting my MAMP server the extension is still stating 1.2.10. Is there something I need to change in my php.ini file? I have already added extension=mongo.so

If you ran sudo pecl install mongo, you likely upgraded the driver for the system install of PHP, which is in a different path than MAMP. There should be a pecl binary within the MAMP path (e.g. /Applications/MAMP/bin/php/php5.x.x/bin), which should be run instead. You may find this blog article as helpful walk-through for the process.

sudo pecl upgrade mongodb worked for me today.

Related

Install MongoDB PHP Extension for PHP 8.1 (Debian)

sorry if there is a duplicate question for this but I'm trying to set this up for hours now and it just doesn't work.
I have a Debian 11 server with "KeyHelp" installed on it (little brother of plesk). It comes with PHP 7.4 but provides a simple Dashboard where you can install other PHP versions. I installed PHP 8.1 and tried to install the mongodb extension via PECL.
After "pecl install mongodb" I added "extension=mongodb.so" and after that didn't show up the extension on the phpinfo page, I double checked if the extension is really in the extension folder of php, where it was.
Turns out that I installed the extension for PHP 7.4 and not for PHP 8.1. Finally I tried to force PECL to install it for PHP 8.1 but it says "phpize8.1 command not found". I found no way to install phpize8.1, can somebody help me out with that?
Thanks in advance!
I am using Ubuntu 20.04
I have PHP 8.1 version. You have to install modules of PHP
sudo apt install php8.1-mongodb
List the modules
php -m
It's not exactly Debian. I hope it helps you.
If you run command:
sudo apt install php-dev
System will install automatically the correct version of php{x}-dev for your distribution, and all it's dependencies, included PECL.
another way is try to run:
/usr/bin/phpize
If this command works, you need to add phpize to your PATH:
PATH=$PATH\:/usr/bin; export PATH
In this way phpize will work in future.

Installing Mongodb PHP Drivers on Ubuntu 18.04

I have installed mongodb on a new Ubuntu 18.04 server. I can access and work with the database through the command line, but cannot access it via PHP, and was wondering how other people have gotten it to work.
Following a new build of Ubuntu 18.04, and installation of LAMP, I ran:
sudo apt install mongodb-server php-pear php7.2-dev
sudo pecl install mongodb
I then added the mongodb.so extension to the php.ini file, and a phpinfo(); page shows mongodb as installed. So far so good.
If I browse to a test php page ($mongo=new Mongo();), the page fails to load though.
Through web searches, I find the https://github.com/alcaeus/mongo-php-adapter page come up a lot, and I have run the composer installation command there, but to no avail.
Installed versions are: Ubuntu 18.04.2 LTS; mongoDBv3.6.3; php 7.2.17; Apache 2.4.29
I was wondering what steps other people who have gotten PHP to work successfully with Mongodb have followed? I plan to scrap this server and start from a fresh VM install again.
I was able to install php-mongodb after adding the ppa repository ondrej/php:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php-mongodb
try:
sudo apt-get install php-mongodb
worked for me
It appears that you're attempting to use the Mongo class from the legacy driver, but you're using the non-legacy driver so that class doesn't exist. Please look at the documentation for the updated version of the driver here. You might also consider using the MongoDB PHP Library to abstract away many of the driver calls.
Please note that there are also compatibility considerations between your versions of the PHP library, MongoDB, and the MongoDB PHP driver. You can find the compatibility information for them here.

Trouble installing mssql extensions for PHP

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.

Does the mongodb php driver require php5-dev?

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

how to install Moodle with Postgre

i am installing Moodle 2.1 with postgre database. the problem i am facing is that it gives me error
PHP has not been properly configured with the PGSQL extension so that
it can communicate with PostgreSQL. Please check your php.ini file or
recompile PHP.
i have adjusted all the required extension for pgsql. but still i get the same error. i have even created a database in postgre (an empty database) but still i didnt work.
please help me
thanks
Have you tried (command line):
apt-get install php5-pgsql
apache2ctl restart
Or:
sudo apt-get install php5-pgsql
sudo apache2ctl restart
I had a lot of trouble, because the version of Moodle I have (3.3) wants a newer version of php than I have on my Ubuntu 14.04. I had 5.5.9 and Moodle insisted on 5.6. So I upgraded php5 to php5.6 with a special ppa. But what happened was it put the new php5.6 next to the old one. So I kept having trouble with Apache, until I set soft links to libphp5.so from my new libphp5.6.so, and set the conf and load files in mods-available to the new php5.6 versions.
Then I had a problem with the postgresql php driver. I tried installing php5-pgsql and it was always linking back to the old php 5.5.9 on Ubuntu! This did not make moodle happy. Then I discovered that there is a php5.6-pgsql. I uninstalled my php5-pgsql and installed php5.6-pgsql. Uff. And added these two lines to php.ini (inside the /etc/php5/apache2 directory):
extension=/usr/lib/php/20131226/pdo_pgsql.so
extension=/usr/lib/php/20131226/pgsql.so
Now moodle can move on to the next error (the php xml extension)!
sudo apt-get install php5-pgsql fixed it for me despite the fact that my vhost on Plesk runs PHP7.0. Now I can use the CLI in Moodle with PostgreSQL.

Categories