Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

replicant's avatar

MSSQL Laravel Herd

I'm running Laravel Herd on a Macbook M4.

I had MSSQL working with php 8.3.15 but when I updated to php 8.3.17 it stopped working. I went back through the setup process outlined here: https://laracasts.com/discuss/channels/tips/herd-and-ms-sql-drivers-on-macos

but now I'm getting this error : SQLSTATE: IMSSP Code: -49 Message: This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for arm64: https://go.microsoft.com/fwlink/?LinkId=163712

I have the msodbcslq18 installed. It seems like it's there but I don't think php is using it. Has anyone ever dealt with this before?

0 likes
5 replies
LaryAI's avatar
Level 58

To resolve the issue with MSSQL not working after updating PHP on Laravel Herd, you need to ensure that the Microsoft ODBC Driver for SQL Server is correctly installed and configured for your PHP version. Here are the steps you can follow:

  1. Verify ODBC Driver Installation: Make sure that the ODBC driver is installed correctly. You can check the installed ODBC drivers by running the following command in your terminal:

    odbcinst -q -d
    

    Look for entries like ODBC Driver 18 for SQL Server. If it's not listed, you may need to reinstall the driver.

  2. Reinstall the ODBC Driver: If the driver is not installed, or if you suspect it might be corrupted, reinstall it using Homebrew:

    brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
    brew update
    brew install --no-sandbox msodbcsql18
    
  3. Check PHP Configuration: Ensure that the pdo_sqlsrv and sqlsrv extensions are enabled in your PHP configuration. You can check this by running:

    php -m | grep sqlsrv
    

    If they are not listed, you need to enable them. You can do this by adding the following lines to your php.ini file:

    extension=pdo_sqlsrv
    extension=sqlsrv
    
  4. Verify PHP-FPM Configuration: If you are using PHP-FPM, make sure to restart it after making changes to the php.ini file:

    brew services restart php
    
  5. Check for Compatibility: Ensure that the versions of the ODBC driver and the PHP extensions are compatible with your PHP version. Sometimes, updating PHP can lead to compatibility issues with existing extensions.

  6. Test the Connection: Create a simple PHP script to test the connection to your MSSQL database:

    <?php
    $serverName = "your_server_name";
    $connectionOptions = [
        "Database" => "your_database",
        "Uid" => "your_username",
        "PWD" => "your_password"
    ];
    
    //Establishes the connection
    $conn = sqlsrv_connect($serverName, $connectionOptions);
    
    if ($conn) {
        echo "Connection established.";
    } else {
        echo "Connection could not be established.";
        die(print_r(sqlsrv_errors(), true));
    }
    

    Run this script to see if the connection is successful.

By following these steps, you should be able to resolve the issue with MSSQL not working after your PHP update on Laravel Herd. If the problem persists, consider checking the Laravel Herd and PHP logs for more detailed error messages.

colincameron's avatar

Did you get anywhere with this? I've got the same issue on 8.3.17 and 8.4.4

kokoshneta's avatar

Since I just had to deal with this, I thought I would add that this is actually covered in the Herd Knowledge Base (though I spent lots of time Googling before happening to click there).

Apparently, Homebrew installs the ODBC drivers in a different location to where Herd(?) expects to find it, so you need to symlink the actual install location to the expected one. On an ARM/Silicon machine, run:

sudo ln -s /opt/homebrew/etc/odbcinst.ini /etc/odbcinst.ini
sudo ln -s /opt/homebrew/etc/odbc.ini /etc/odbc.ini

On an Intel machine, run:

sudo ln -s /usr/local/etc/odbcinst.ini /etc/odbcinst.ini
sudo ln -s /usr/local/etc/odbc.ini /etc/odbc.ini

That fixed it for me.

jdc1898's avatar

This is and almost likely always will be the case. Since herd can run multiple versions of PHP, you have to make sure the version of ODBC and the PHP module are linked and are in the .ini files for each version. This can be a PITA if you have different version of Ms SQL for instance. You may be ODBC 17 and 18 and it compiled against PHP 8.2 and 8.3.

In my opinion, this is were containers and/or virtual environments shine. If keeps everything together and neat to easily switch between development projects.

Lastly, triple check that you install the ARM versions if on Apple silicon. I’ve seen a lot of people speed days trying to figure out why it won’t work when they accidentally compiled the wrong binaries.

Please or to participate in this conversation.