Could not find driver sqlsrv PHP 8.0.1

14,514

Solution 1

From what I read after the release of PHP 8, the dll extentsion for pdo_sqlsrv won't be out until the end of January. I had the same issue when 7.4 rolled out and I had to wait a couple months for the appropriate dll to be release for our Windows server. I'll try and remember to come back and update with the link if I find it released.

Solution 2

I found myself in a similar case having difficulties installing my SQLSRV drivers to work with PDO in PHP and connecting to my Microsoft SQLServer server, in my particular case I installed XAMPP locally

To test and check what version of PHP I had and verify that my drivers will work, use the following:

Create info.php and execute this file locally in your browser

http://localhost/info.php.

Important to mention that you must place it in your C:\xampp\htdocs folder, in my case I am using XAMPP

<?php 
phpinfo(); 
?>

I have PHP Version 8.0.3 And in the PDO section you will find PDO support PDO drivers, there you must find sqlsrv active if all goes well, as well as a section on pdo_sqlsrv with version 5.9.0 enabled.

PDO Active Drivers Section if they are not shown in the enable column something is wrong

Download SQLSRV59.EXE from Microsoft Drivers 5.9 for PHP for SQL Server is the latest general availability (GA) version

You will have to execute the file that you download and later copy the .dll files that correspond to the version you require inside the folder

C:\xampp\php\ext

I copy the next files (my windows is x64 and PHP 8.0.3)

php_pdo_sqlsrv_80_nts_x64.dll php_pdo_sqlsrv_80_ts_x64.dll php_sqlsrv_80_nts_x64.dll php_sqlsrv_80_ts_x64.dll

In this download you will find .dll x86 and x64

php_pdo_sqlsrv73 php_pdo_sqlsrv74 php_pdo_sqlsrv80

I installed the Microsoft SQL Management Studio 18 but in case of not installing it you will need the

Microsoft ODBC Driver 17 for SQL Server

In the window XAMPP Control Panel search the CONFIG button the Apache Module, and select the option PHP (php.ini)

add this lines (according to the names of the .dll files that you copied inside the folder)

SEARCH in php.ini the section EXTENSIONS

; Mi CONFIGURACIÓN SQL SERVER
extension=php_pdo_sqlsrv_80_nts_x64.dll
extension=php_pdo_sqlsrv_80_ts_x64.dll
extension=php_sqlsrv_80_nts_x64.dll
extension=php_sqlsrv_80_ts_x64.dll

save the file and restart the apache server. press the stop button and then start

I hope you find it useful

Share:
14,514
Luis Luis Maia Maia
Author by

Luis Luis Maia Maia

By day: a simple webStarter and a little bit WebDesigner. By night: Im a night rider, just me myself and the VW. For fun: go karts, and everything with wheels.

Updated on June 04, 2022

Comments

  • Luis Luis Maia Maia
    Luis Luis Maia Maia almost 2 years

    I´m currently trying to enable the pdo_sqlsrv extension.

    I downloaded the drivers from here: https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15

    And then added them to the folder php/ext/

    After that i added the following line to the php.ini

    extension=php_sqlsrv_72_ts.dll
    

    The error log shows me the following:

    [12-Jan-2021 16:06:23 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'php_sqlsrv_72_ts.dll' (tried: C:\php\ext\php_sqlsrv_72_ts.dll (Impossível localizar o módulo especificado), C:\php\ext\php_php_sqlsrv_72_ts.dll.dll (Impossível localizar o módulo especificado)) in Unknown on line 0
    

    I already tried also just add the following line:

    extension=php_pdo_sqlsrv
    

    The error log file shows:

    [12-Jan-2021 16:17:55 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv' (tried: C:\php\ext\php_pdo_sqlsrv (Impossível localizar o módulo especificado), C:\php\ext\php_php_pdo_sqlsrv.dll (Impossível localizar o módulo especificado)) in Unknown on line 0
    

    Note: Im using PHP with IIS. Also others drivers like pdo_odbc work. I only have problems with this one.

    After following suggesting from comments:

    I isntalled the drivers from the following link: pecl.php.net/package/pdo_sqlsrv/5.9.0beta2/windows

    Added to php.ini

    extension=pdo_sqlsrv
    

    And error log file stills says it can't find the module:

    [12-Jan-2021 20:59:17 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlsrv' (tried: C:\php\ext\pdo_sqlsrv (Impossível localizar o módulo especificado), C:\php\ext\php_pdo_sqlsrv.dll (Impossível localizar o módulo especificado)) in Unknown on line 0
    
    • Zhorov
      Zhorov over 3 years
      Based on change log you need PHP Driver for SQL Server, version 5.9 for PHP 8.0.1 File php_sqlsrv_72_ts.dll is extension DLL file for PHP 7.2
    • Luis Luis Maia Maia
      Luis Luis Maia Maia over 3 years
      @Zhorov I edited my question after your suggestion. Thanks in advanced
  • Luis Luis Maia Maia
    Luis Luis Maia Maia over 3 years
    Thanks I would appreciated.
  • UM-ISRphp
    UM-ISRphp about 3 years
    Sorry, forgot to post this when I found it. You can grab the new ones at - docs.microsoft.com/en-us/sql/connect/php/…
  • devnull Ψ
    devnull Ψ over 2 years
    any update here? cant install pdo_sqlsrv extension with php 8
  • Nouphal.M
    Nouphal.M about 2 years