DEV Community

retinqdon
retinqdon

Posted on

Setting up Laravel with SQL Server AND Laragon on Windows

I just want to share how I connect my laravel project with sqlserver.

I assume that you already have Laragon and SQL Server in your local system.

Step 1. Download the PHP driver here

  • Go to the bottom of the page then download windows-8.1.zip (since I'm using PHP 8.1 Image description
  • Extract the zip file to a folder, then go to folder named x64, you will see the following dll Image description
  • Then copy these dll to your php folder inside the laragon folder, mine is C:\laragon\bin\php\php-8.1.5-nts-Win32-vs16-x64\ext Image description
  • Then Edit your php.ini, add the extension Image description
  • Then restart your laragon server

Step 2. Make a new laravel app using laragon quick app menu
Image description
Image description

  • Then we need to update the .env file ```

DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=1433
DB_DATABASE=lara-sqlserver
DB_USERNAME= sa
DB_PASSWORD= 12345678

  * Next, create the database in sql management studio, mine is lara-sqlserver
  * Before running the migration, make sure to enable tcp-ip in sql configuration manager
   ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opikbte4ce6kxwgqvbl5.png)

  * then run the migration

Enter fullscreen mode Exit fullscreen mode
 php artisan migrate
Enter fullscreen mode Exit fullscreen mode
  * if everything works fine you should see this in your terminal
     ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iyhnoaaphswfoqss9zml.png)

**Thanks guys!**
Enter fullscreen mode Exit fullscreen mode

Top comments (0)