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

yudo's avatar
Level 9

Laravel Herd on Windows with MS SQL driver

I would like to install MS SQL driver for Laravel Herd. Any ideias how? I saw another discussion, but its for MAC OS. I would like this to work on windows

0 likes
3 replies
LaryAI's avatar
Level 58

To install the MS SQL driver for Laravel Herd on Windows, you'll need to ensure that you have the necessary drivers and extensions installed for PHP to communicate with a Microsoft SQL Server database. Here's a step-by-step guide to help you set it up:

  1. Install the ODBC Driver: You need to install the ODBC driver for SQL Server. You can download it from the official Microsoft website. Choose the version that matches your system architecture (32-bit or 64-bit).

  2. Enable the PHP SQLSRV Extension: You will need to enable the sqlsrv and pdo_sqlsrv extensions in your PHP installation.

    • Download the appropriate version of the SQLSRV and PDO_SQLSRV drivers from the Microsoft website. Make sure to select the version that corresponds to your PHP version and thread safety (nts - non-thread safe or ts - thread safe).
    • Extract the downloaded files and place the php_sqlsrv.dll and php_pdo_sqlsrv.dll files into your PHP extensions directory (usually ext within your PHP installation directory).
    • Edit your php.ini file to include these extensions by adding the following lines:
      extension=php_sqlsrv.dll
      extension=php_pdo_sqlsrv.dll
      
    • Restart your web server to apply the changes.
  3. Configure Laravel Herd: In your Laravel Herd environment, you will need to configure the database connection to use the SQL Server driver.

    • Open your .env file and set the DB_CONNECTION to sqlsrv.
    • Also, provide the necessary credentials and information for your SQL Server database in the .env file:
      DB_CONNECTION=sqlsrv
      DB_HOST=your_sql_server_host
      DB_PORT=your_sql_server_port (default is 1433)
      DB_DATABASE=your_database_name
      DB_USERNAME=your_sql_server_username
      DB_PASSWORD=your_sql_server_password
      
  4. Test the Connection: Once you have configured the .env file, you can test the connection to the SQL Server by running a migration or using Laravel Tinker to attempt to retrieve data from the database.

  5. Troubleshooting: If you encounter any issues, make sure that:

    • The ODBC driver is installed correctly.
    • The sqlsrv and pdo_sqlsrv extensions are enabled in your php.ini file.
    • Your web server has been restarted after making changes to the php.ini file.
    • The database credentials in your .env file are correct.

By following these steps, you should be able to install and configure the MS SQL driver for Laravel Herd on a Windows environment. If you run into any specific errors during the process, you may need to consult the error messages and documentation for further troubleshooting.

yudo's avatar
Level 12

I was able to install on windows, follow these steps:

extension=php_sqlsrv_83_nts_x64.dll

extension=php_pdo_sqlsrv_83_nts_x64.dll

  • again, these are my version (PHP 8.3 non thread safe for x64 machine), but may vary.
  • restart PHP and NGINX services and you should now have MS SQL driver working.
3 likes

Please or to participate in this conversation.