Trouble installing mssql extensions for PHP - 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.

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.

MongoDB installation on Mac OS X 10.11, with MacPorts

I am trying to install MongoDB on my computer running Mac OS X 10.11 (El Capitan).
My Apache + PHP configuration was already working correctly.
I installed MongoDB and PHP drivers for MongoDB through MacPorts:
sudo port install mongodb
sudo port install php55-mongodb
Installation ran correctly.
I added mongodb.so file to the extensions loaded in the php.ini file:
extension=/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/mongodb.so
When I run phpinfo() function in php file, mongodb extension seems to be loaded correctly:
I tried to test my connexion by initializing a MongoClient instance:
<?php
$mongoDB = new MongoClient();
var_dump($mongoDB);
?>
Unfortunately, I got a HTTP ERROR 500, and I got the following line in my Apache logs:
PHP Fatal error: Class 'MongoClient' not found in ...
Did I make something wrong ?
On most of site I saw you need to add the extension mongo.so and not mongodb.so in your php.ini.
If it's not solved your problem, I recommand you to install MongoDB Drive with PELC.
Run command line:
$ sudo pecl install mongo
And add this line to your php.ini:
extension=mongo.so
Doc php.net Mongo Installation
Finally found a solution to my problem.
As #neverpanic and #Zagonine made me understand, php-mongodb and php-mongo are not the same extension.
If you want to use old PHP driving classes, you should use php-mongo package instead of the very new php-mongodb.
Trying to install latest php-mongo extension, I had an other problem related to OpenSSL. To bypass it, I installed an old version of php-mongo extension:
sudo /usr/local/pear/bin/pecl install mongo-1.5.8
Hopefully it will help someone else.

Having issue in installing mongoDB PHP driver

I am very new to mongoDB. I have downloaded the setup for mongoDB but before that I have to install the mongoDB PHP driver.
When I downloaded the driver I got these instruction in the documentation:
Installation
To install:
$ phpize
$ ./configure
$ make
$ sudo make install
When I run this command phpize on cmd then it gives me this error
'phpize' is not recognized as an internal or external command.
I am using:
MongoDB version 1.0
PHP version 5.5
Windows 7
I was having a similar issue a week ago. I struggled a lot and finally found that I had downloaded the wrong DLL file. (My system is 64-bit, so I downloaded the DLL for 64-bit. However, phpInfo() shows that my php is 32-bit. So, I downloaded the 32-bit DLL file and it worked!)
Have a look at the following tutorial if you still have any queries:
https://www.youtube.com/watch?v=HBKNKl5OG_8&t=356s
I hope that helps!

Update/Upgrade PHP MongoDB driver

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.

Error installing MongoDb PHP driver with XAMPP on Max OS Lion

I get this error when i try to run following command
sudo pecl install mongo
Error:
...php_mongo.c:22:10: fatal error: 'php.h'
file not found
#include <php.h>
^
1 error generated.
make: *** [php_mongo.lo] Error 1
ERROR: `make' failed
I am new to MAC, please help me to resolve this and get Mongo Working with PHP.
I have installed MacPorts and autoconf
It seems, that you did not install the xampp "Developer Package", required to build additional php extension. You can download the "Developer Package" from:
http://www.apachefriends.org/en/xampp-macosx.html#849
This has already been answered.
Please follow the processes outlined in this answer - Install PECL on Mac OS X 10.6.
I followed the process outlined here http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/, referenced by the above Stackoverflow link and the process for install pear, followed by pecl and subsequently -
sudo pecl install mongo
works perfectly on OSX Lion.
You may need to modify the extensions in /etc/php.ini, however, this is explained in the output after you install the php mongo driver.
It took me the whole day to find this answer, I had tried everything, but this worked finally:
sudo C_INCLUDE_PATH=/usr/local/opt/openssl/include /Applications/XAMPP/xamppfiles/bin/pecl install mongodb
I found this article very helpful. Saved a lot of time after I wasted a lot of time to check other links. I did for MAMP and think will work for XAMPP too.
The thing is MAMP does not ship with all PHP sources to compile pecl mongo file and create mongo.so. All what you need is download php for respective version you are using. I was using php version 5.6.10. I checked php.net site that was having 5.6.13 version. I downloaded sources for this version from PhP.net. Executed "sudo pecl install mongo" again and it worked.

Categories