Tutorial: How to add PHP extensions to Laragon (ex: Microsoft SQL Server)
-
Adding PHP extensions to Laragon is very easy. This tutorial will show you how to use MS SQL Server extensions.
Download the latest release here:
https://github.com/Microsoft/msphpsql/releasesIf you are using PHP 7.1,
download: https://github.com/Microsoft/msphpsql/releases/download/v4.2.0-preview/Windows-7.1.zip
There are many files in the zip, but you can decide which dll from your PHP Version.
If your PHP version is: php-7.1.5-Win32-VC14-x64, you should use:- x64 >
php_pdo_sqlsrv_71_ts.dll
- x64 >
php_sqlsrv_71_ts.dll
Copy the two to ext dir (Menu > PHP > dir:ext), then go to Menu > PHP > Extensions and click to the dll names to enable them.
That's all. No need to restart Apache or do something else.
To test if it works:
Use phpinfo() and search: sqlsrv
You will see:
If you are using PHP 5.6:
Download Microsoft drivers 3.2 (https://www.microsoft.com/en-us/download/details.aspx?id=20098)
- x64 >
-
Note: In some cases you need to install ODBC driver:
https://msdn.microsoft.com/en-us/library/cc296170.aspx
Test connection:
test-con.php
<?php $serverName = "sqlsrv"; //Hostname/IP,... $connectionOptions = array( "Database" => "tempdb", "Uid" => "di", "PWD" => "di" ); //Establishes the connection $conn = sqlsrv_connect($serverName, $connectionOptions); if( $conn === false ) { die( print_r( sqlsrv_errors(), true)); //See why it fails } else { echo "Connected!"; }