I'm trying to load the MongoDb extension for php on a Windows 7 64 bit PC, running XAMPP with Apache 2.0 and PHP 5.3.5, compiler version VC6. I started out with this tutorial, and have also tried the extensions that the php documentation suggested. MongoDb itself is running fine, and shell commands seem to work.
At the moment I have:
Added extension=php_mongo.dll to my php.ini file.
Put the VC6 version of php_mongo.dll (from the following download page, suggested by the PHP documentation) in the php/ext folder.
Restarted my Apache server.
I have also tried php_mongo.dll files form Stealth's github, but they didn't seem to work either.
When restarting Apache, I don't get any errors, but I can't find anything on MongoDb in phpinfo(), and the Mongo class is not recognised either.
Any ideas of what might be wrong? Let me know if you need more info.
The problem might be incorrect version of extension. Try different versions downloaded from here: http://pecl.php.net/package/mongo/1.6.4/windows
Use Bitnami WAMP Stack instead of XAMPP it comes preloaded php_mongo.dll driver installed and no need to configure php.ini file
There is no official MongoDB Driver released for PHP7. So it would be better to download the recommended PHP version 5.5.30(currently) offered by Bitnami Wamp Stack.
There might be two reasons:
First one is as #Sadd suggested. Your mongodb extension should be loaded after what you have done so its very likely that you have enabled extension in wrong file. And yes, there are two such similar files (named php.ini-development and php.ini-production on windows computers), so make sure to enable it in php.ini file and run the following code echo extension_loaded("mongodb") ? "loaded\n" : "not loaded\n"; and you should see loaded on screen.
If you still don't see it, then the second thing you can do is to check whether the version is right or not. You can check your phpinfo() for your php version and then put the right versioned dll file in ext folder. In this, you can have to check whether your php is ts or nts and second one is whether your php is x64 or x86. I hope you are good to go after one or both of the changes.
This was driving my crazy until I looked closely at my PHP version:
$ php -v
PHP 7.4.1 (cli) (built: Dec 17 2019 19:23:59) ( NTS Visual C++ 2017 x64 )
Notice that it says PHP 7.4.1 and NTS and x64? This means that when I download from PECL, I need version 7.4 Non Thread Safe (NTS) x64 or it won't run correctly.
If the correct version of module is not added, an error is thrown.
[PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: C:\xampp\php\ext\php_mongodb.dll (The specified module could not be found), C:\xampp\php\ext\php_php_mongodb.dll.dll (The specified module could not be found)) in Unknown on line 0]
When downloading the dll extension from https://pecl.php.net/package/mongodb, make sure that NTS (Non Thread Safe) or TS (Thread Safe) is chosen according to what shown from php -v command.
$ php -v
PHP 8.1.7 (cli) (built: Jun 7 2022 21:45:53) (ZTS Visual C++ 2019 x64)
Although here it shows ZTS, TS version can be used in this case.
Related
I'm trying to get a connection to MS SQL up and running via PHP on my machine. I'm running IIS, have PHP 7.2 installed and MS SQL Express 2017. I have my basic web page running but when I click to open the PHP page, the connection does not work.
session_start();
echo "Hello ";
if (isset($_POST['submit'])) {
$_SESSION["server"] = $_POST['server'];
$_SESSION["database"]= $_POST['database'];
$_SESSION["username"] = $_POST['username'];
$_SESSION["password"] = $_POST['password'];
echo $_SESSION["database"];
//CONNECTION
$serverName = $_SESSION["server"];
$connectionInfo["Database"] = $_SESSION["database"];
$connectionInfo["UID"] = $_SESSION["username"];
$connectionInfo["PWD"] = $_SESSION["password"];
echo "midway";
$conn = sqlsrv_connect($serverName, $connectionInfo);
echo "Bye";
}
When I run this I get "Hello dimensions midway" which suggests the page is working until it hits the connection line.
I am not sure what sqlsrv extension to use.
I have looked around and can see versions for 7 and 7.1 but not for 7.2.
I have added in extension=php_sqlsrv_71_nts_x86.dll to the bottom of php.ini (and the file exists in C:\Program Files (x86)\PHP\v7.2\ext).
Any pointers would be gratefully received. I've spent a couple of days on this and don't think I'm getting anywhere.
Thanks
I faced the same issue. Later I found that I was using older version of Microsoft SQL files for PHP.
For PHP 7.2 you have to use 7.2 version of MS PHP SQL
That version is not available through microsoft website. I found it here https://github.com/Microsoft/msphpsql/releases
Once I used those files everything works fine. I used 64 bit files.
Then you need to add these lines in the php.ini file
extension=php_sqlsrv_72_nts.dll
extension=php_pdo_sqlsrv_72_nts.dll
What do you need to determine are
Which version of PHP
The runtime you are using is Thread Safe or Non-Thread Safe
The runtime you are using is 64 bits or 32 bits
Then you must look at the requirement page here
Check the version of PHP you are using, so prefer to your question, it's mean to PHP 7.2 which SQL Server extension version 5.3 is the best fit.
Then go to download page, select the link which specific with version you prefer. (in this question is 5.3)
The file you downloaded will be a self-extractable EXE file, then extract to the place where you want.
you will see list of dll files like these...
php_pdo_sqlsrv_7_nts_x64.dll
php_pdo_sqlsrv_7_nts_x86.dll
php_pdo_sqlsrv_7_ts_x64.dll
php_pdo_sqlsrv_7_ts_x86.dll
...
php_sqlsrv_72_ts_x86.dll
What is the meaning that is in the name of these files?
Like I said before, what you need to determine to select the proper extension file. The SQL Server extension need 2 files of the name start with php_pdo_sqlsrv_xxx and php_sqlsrv_xxx.
Next number mean to your PHP version, in this case PHP 7.2, so you need to choose file name has _72_ in its.
Next number mean to your runtime Thread Safe or Non-Thread Safe, which specific in the file name _ts_ (Thread Safe) or _nts_ (Non-Thread Safe).
Next number mean to your runtime 32 bits or 64 bits, which specific in the file name _x86 (32 bits) or _x64 (64 bits)
So check your PHP environment by phpinfo(), or run the command php --version on your console, and then notice the message displayed, for my computer it look like these...
PHP 7.2.12 (cli) (built: Nov 8 2018 06:12:12) ( ZTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
By look from those information, I got PHP 7.2, ZTS mean to Thread Safe (Non-Thread Safe will be NTS), and the x86 is 32 bits.
So, what I must pick is the extension which are php_sqlsrv_72_ts_x86.dll and php_pdo_sqlsrv_72_ts_x86.dll
Final: copy them to your /php/ext folder and edit php.ini with those 2 files name.
// example with my case
extension=php_pdo_sqlsrv_72_ts_x86
extension=php_sqlsrv_72_ts_x86
Then save php.ini file and then restart your server.
Test your result by looking at phpinfo.php, which MUST has pdo_sqlsrv in the page. That's mean your environment can run PHP and connect to SQL Server now.
I solved it ~
PHP Version 7.2.4
pdo_sqlsrv : 5.3.0+11108
1.download the proper version sqlsrv and sqlsrv pdo
2.put it into XAMPP\PHP\ext folder
3.after that write the line into php.ini > module setting
extension=php_pdo_sqlsrv_72_ts.dll
extension=php_sqlsrv_72_ts.dll
4.let's make a test for MSSQL still there is a error msg for recommend you to download ODBC Driver for SQL
5.Go to https://learn.microsoft.com/zh-tw/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017 then download the proper file
(mine is Command Line Utilities 11 for SQL ServerĀ® X86)
6.fire the test.php again everything works!
I finally found the solution. All you have to do is use these extensions in php.ini file.
php_sqlsrv_72_ts_x86.dll
php_pdo_sqlsrv_72_ts_x86.dll
and restart your XAMPP.
P.S. "I am using PHP 7.2.5 "
How to use SQL Server DLL files with PHP 7.2 version on xampp
https://github.com/Microsoft/msphpsql/releases
To download Windows DLLs for PHP 7.1 or above from the PECL repository, please go to the SQLSRV or PDO_SQLSRV PECL page.
https://pecl.php.net/package/sqlsrv/5.6.1/windows
https://pecl.php.net/package/pdo_sqlsrv/5.6.1/windows
NOTE: Do not forget to remove php_ prefix when you add extension dll filename in php.ini file. eg.
extension=pdo_sqlsrv
extension=sqlsrv
** Do not change actual filename which you put in /xampp/php/ext/ directory.
7.2 Thread Safe (TS) x86 worked for me for sqlsrv and pdo_sqlsrv extensions.
Restart xampp or apache then you can see enabled pdo_sqlsrv extension when you print phpinfo() in a test php file
In my apache error.log I have the following line:
PHP Warning: PHP Startup: Unable to load dynamic library 'ext\\php_curl.dll' - The specified procedure could not be found.\r\n in Unknown on line 0
However I have checked my PATH variable and the PHP directory is listed, the ext folder is set correctly and php_curl.dll exists in the folder.
I have reinstalled VC++ redistributes to ensure that there are no issues there.
During my checking I have found that all of the following DLLs are present when opening them from run (to test they can be found from the PATH variable):
ws2_32.dll
wldap32.dll
php7ts.dll
libeay32.dll
libssh2.dll
nghttp2.dll
ssleay32.dll
normaliz.dll
kernel32.dll
vcruntime140.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
I am unsure of what dependencies that php_curl could have, if you could provide any suggestions then this would be greatly appreciated.
More system info:
Compiler MSVC14 (Visual C++ 2015)
Architecture x64
Windows 7 platform
PHP version 7.1.4
Apache version 2.4
I have the same issue. I was not able to find the root cause for this error but I managed to find a fix. Simply copied php_curl.dll from previous version of php I used - 7.1.2 x86 Thread Save. Everything works fine for now.
I have installed APACHE 2.4 x64 and PHP7 x64 and download PHP OCI 64bit libraries but the problem is that whenever I run PHP script from cli it says
PHP Startup: Unable to load dynamic library
'E:\software\server\php-7.0.11-Win32-VC14-x64\ext\php_oci8_11g.dll' -
%1 is not a valid Win32 application
Also when I invoke the webapplication from URL it says
Call to undefined function oci_pconnect()
The OCI extension I downloaded are also 64bit. Here is the link:
http://windows.php.net/downloads/pecl/releases/oci8/2.1.2/php_oci8-2.1.2-7.0-ts-vc14-x64.zip
Can someone guide on this problem.
You've probably mixed TS (thread safe) and NTS (non-thread safe) versions. These will not work together. Find out more about PHP thread safety here.
PHP 7.0.11 NTS x64, OCI8 2.1.2 NTS x64, and InstantClient 11.2.0.4.0 x64 work perfectly well together (I've just downloaded these three files and tested them in a fresh Win2K8 environment).
Remember to install the latest VC14 runtime (Visual Studio 2015) and to modify your PATH system environment variable to include the directories of PHP and the InstantClient, e.g. C:\php;C:\instantclient_11_2.
When I check my php version I get the following warnings:
PHP Warning: PHP Startup: ssh2: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match
in Unknown on line 0
I'm trying to understand which versions work together and how I can get hold of the correct version to setup PHP with SSH2. I have been able to find the .tar.gz versions of libssh from places like the following:
https://www.rpmfind.net/linux/RPM/remi/enterprise/6/x86_64/php56-php-pecl-ssh2-0.12-4.el6.remi.x86_64.html
The problem is I am using a Windows machine and not Linux. Does anyone know whether I can get the same libssh version for Windows? Or do I have to downgrade PHP to the same level as ssh2? Or is it nothing to worry about it and just a quirk of Windows?
Here are some details that might be of use:
OS: Windows 10 (x64)
PHP Version: PHP 5.6.15 (cli) (built: Oct 29 2015 12:39:50)
Microsoft Visual C++ 2015 Redistributable (x64) 11.0.61030
Server version: Apache/2.4.17 (Win64)
Apache Lounge VC11 Server built: Oct 13 2015 11:37:51
In addition... I've found the version of the ssh2 zip that I downloaded. It was 5.5 Thread Safe (TS) x64 from: https://pecl.php.net/package/ssh2/0.12/windows
So, I guess that means I need to downgrade my PHP to 5.5 for this to work properly. Is that correct or is there a better way?
I've found a solution to the problem. As stated in the OP the problem was that the PHP module was a later version than the SSH2 module. The question was how to find the versions that would work with the setup stated. This proved to be quite tricky because there were more systems that needed to be integrated than I first thought. I falsely assumed that the latest versions would all play nice together.
As I am running Windows 10 64-bit I wanted to get the stable version of PHP that runs against this - that would be PHP 7. As stated here: http://windows.php.net/download/. Initially I downloaded PHP 7.0 but this didn't play nicely with another module that I wanted to install, which was MongoDB.
When I looked into MongoDB I realised that there wasn't a driver for PHP 7.0 yet so the latest one I could get was PHP 5.6. This meant that I had to settle for an "experimental" 64-bit version of PHP. So I made the shift and everything was playing nice until I decided that I wanted to get Composer so that I could manager my PHP dependencies.
When I tried to intall Composer using the Windows installer it failed with an unknown exception and suggested I try from the command line to get a better error response. So I duly did and the error stated that the ssh2 module was not compatible with PHP 5.6.
That eventually brought me to ask the question on stackoverflow.
After some more digging into what versions of ssh2 there are I was brought to the following page: http://windows.php.net/downloads/pecl/releases/ssh2/0.12/
This told me that the latest version of PHP that was compatible with the SSH2 extension was PHP 5.5. So... it looks like the solution was to downgrade to version 5.5.
When I started looking for the new (old) version to download I came across this wonderful bundle package site: https://www.apachelounge.com/viewtopic.php?t=6123
From there I could download this version (https://phpdev.toolsforresearch.com/php-5.5.20-Win32-VC11-x64.zip) and it would contain all the modules that I needed in the correct version.
So, in conclusion, a little more up-front analysis into what versions play nice together would have helped or understanding that the Apache Lounge has all the versions that work together in a nice tidy bundle.
I am trying to get php_ssh2.dll working on my IIS 7.5 server.
I have PHP 5.5.4 installed and running (NTS VC11 x64).
I downloaded php_ssh2.dll from here: http://windows.php.net/downloads/pecl/releases/ssh2/0.12/php_ssh2-0.12-5.5-nts-vc11-x64.zip
I placed the extension and the pdb file in the ext folder of my PHP install and enabled it in IIS.
The problem is when I restart IIS, I get the following in my error log:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\5.5.4\ext\php_ssh2.dll' - %1 is not a valid Win32 application. in Unknown on line 0
I also have PHP 5.3 installed with php_ssh2.dll (not the same as linked above) and it works fine.
I do have libssh and openssl installed, as well as Visual C++ 2012 x64.
Is there some other step I'm missing?
Minor update, I tried doing everything above with the x86 builds instead and had the same results. PHP itself runs fine, but I cannot utilize the php_ssh2.dll
It appears the issue is that the 5.5x builds of the php_ssh2.dll lack the libssh2.dll, per this bug report: http://www.phplt.com/2013/09/17/17/php_ssh2-0-12-5-5-nts-vc11-x86-zip-missing-file/
Is this something I can build or acquire elsewhere?
What are you trying to do with php_ssh2.dll? Maybe phpseclib, a pure PHP SSH2 implementation, would work better for you?