Regardless of doing a 'clean' installation or just updating some component (OS, PHP, VCxx and MSSQL) it is strongly recommended to check the SQL server driver compatibility with the other components to not install anything wrong. The procedure described below is also used to install the sqlsrv extension.
There is a table which shows which version of the SQL Server driver is compatible with its version of PHP.
1 - Download the microsoft site driver in this link
2 - Unzip the file see driver version with php version and whether it is thread safe or not (see Thread Safety
no phpinfo()
).
3 - Copy the dll to the ext folder of the php installation.
4 - Finally add the extension load in php.ini and restart the server.
extension=php_pdo_sqlsrv_VERSAO_THREAD_SAFE_OU_NAO.dll
For non thread safe
extension=php_pdo_sqlsrv_55_nts.dll
For thread safe
extension=php_pdo_sqlsrv_55_ts.dll
To verify that the extension has loaded correctly, create a new file with the code:
<?php
phpinfo();
If you have no problem, phpinfo will load like the image below:
AnotherwaytocheckifthePDOdriverwasinstalledcorrectlyistouse getAvailableDrivers()
<?php
echo "<pre>";
print_r(PDO::getAvailableDrivers());
The result is something like:
Array
(
[0] => mysql
[1] => sqlsrv
[2] => pgsql
[3] => sqlite
)