Tutorial: How to add PHP extensions to Laragon (ex: Microsoft SQL Server)

  • administrators
    | 46801 points

    Adding PHP extensions to Laragon is very easy. This tutorial will show you how to use MS SQL Server extensions.

    First, downloading Microsoft drivers 3.2 (https://www.microsoft.com/en-us/download/details.aspx?id=20098), and extracting them, please take note of 2 files:

    • php_sqlsrv_56_ts.dll
    • php_pdo_sqlsrv_56_ts.dll

    Note: If you are using PHP 7, please download version 4.x (https://github.com/Azure/msphpsql/releases/download/v4.0.3/x86.zip) and care of 2 files: php_pdo_sqlsrv_7_ts.dll, php_sqlsrv_7_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:

  • administrators
    | 46801 points

    Note: In some cases you need to install ODBC driver:

    Test connection:

    $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!";

Log in to reply

Looks like your connection to Laragon was lost, please wait while we try to reconnect.