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
- Extract the zip file to a folder, then go to folder named x64, you will see the following dll
- 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
- Then Edit your php.ini, add the extension
- Then restart your laragon server
Step 2. Make a new laravel app using laragon quick app menu
- 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
php artisan migrate
* 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!**
Top comments (0)