Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install an SQLSRV extension to php XAMPP

Tags:

php

apache

I'm trying to install a SQLSRV extension. My PHP version is 7.2 (XAMPP 3.2.2) and I use windows 10. I downloaded the .dll from here: https://github.com/Microsoft/msphpsql/releases. Then I unpacked it to the xampp/php/ext folder enter image description here

After that I opened the php.ini and added this extension:

  1. extension=php_pdo_sqlsrv_72_nts
  2. extension=php_sqlsrv_72_nts

Next I restarted the Apache server.

Unfortunately when I open the phpinfo website I don't see the extension. Also when I open the XAMPP shell and type php I'm getting an error.

PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_72_nts' (tried: C:\xampp\php\ext\php_pdo_sqlsrv_72_nts (Module was not found.)

My extension_dir in php.ini is set to extension_dir="C:\xampp\php\ext".

Architecture is x86.

What did I do wrong?

EDIT: I've changed the nts to ts files and now its working.

like image 610
Greg Ostry Avatar asked Jan 15 '18 08:01

Greg Ostry


2 Answers

worked for me by telling in the PHP.ini file in this way:

extension=mysql
extension=sqlsrv
extension=pdo_sqlsrv

so, you have to remove "php_" and ".dll"

like image 135
AleM Avatar answered Nov 03 '22 21:11

AleM


  • Please Make sure the extension and php.ini file is in same path. and you running same php.exe file.
  • If there is no path issue then you can try it:

Remove the

php_

prefix from your php.ini file. because php automatically searching with the name of file with the prefix: php_pdo_sqlsrv_72_ts_x86.dll Example: if you register the dll file as:

pdo_sqlsrv_72_ts_x86

then php will search the dll file as:

php_php_pdo_sqlsrv_72_ts_x86.dll

like image 41
Emtiaz Zahid Avatar answered Nov 03 '22 22:11

Emtiaz Zahid