PDO sqlsrv: could not find driver

After I found the error log on the Windows Server, I solved the error by myself.

I got this error in my log:

[21-Apr-2017 07:12:14 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '...\ext\php_pdo_sqlsrv_7_nts.dll' - %1 is not a valid Win32 application. in Unknown on line 0

Then I downloaded again the driver and installed the x64-Driver. Finally It works without any problems.


Here is detailed process if it's helpful for someone. PHP Version - 7.4

  1. Download and extract the .dll files from this link - https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15

  2. Paste the files in C:\xampp\php\ext, your path could be different.

  3. in php.ini add those two lines at bottom or in extension section.

     extension=php_sqlsrv_74_ts_x64.dll
     extension=php_pdo_sqlsrv_74_ts_x64.dll
    
  4. Restart your Xampp server, I'll suggest restart your computer and everything will work without an issue then.

Check if SqlSRV enabled

Check using phpinfo() or http://localhost/dashboard/phpinfo.php at like this -

SQLSrv Driver Check in PHP Info

Hope, it will help someone.