411 views
asked in Laravel by
Laravel Tutorial - How to connect Laravel to SQL Server

1 Answer

answered by

1. Download SQL Server PHP Drivers from below link:

https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver16

Note :

Make sure you have the latest version of the ODBC driver installed to ensure optimal performance and security. For download visit the below link.

https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16

2. Extract drivers on ext directory inside your php installation directory (example : C:\xampp\php\ext)

Add the following to your php.ini file.

extension=php_sqlsrv_82_ts_x64.dll
extension=php_pdo_sqlsrv_82_ts_x64.dll

3. Update your .env file with the database connection details

DB_CONNECTION=sqlsrv
DB_HOST=CHIRAG-LAPPY\PRIMARYDB
DB_PORT=1433
DB_DATABASE=webcam_app
DB_USERNAME=sa
DB_PASSWORD=admin@123

4. Go to

Sql Server Configuration Manager -> Sql Server Network Configuration -> Protocols For <InstanceName> -> TCP/IP -> IPAddresses

Change the following

IpAll
TCP Dynamic Ports  xxxxx
TCP Port

To:

IpAll
TCP Dynamic Ports xxxxx
TCP Port           1433

5. Now open the sql server management studio and connect the instance. Next create the database "webcam_app" (Create your own databse here we are creating webcam_app database for testing purpose.).

6. run the below command in the project.

php artisan migrate

Most popular tags

postgresql laravel replication laravel-10 ha postgresql mongodb ubuntu 24.04 lts mongodb database mongodb tutorial streaming-replication laravel-11 mysql database laravel postgresql backup laravel login register logout database mysql php technlogy asp.net asp.net c# mysql master slave replication centos linux laravel sql server schedule backup autobackup postgresql django python haproxy load balancer install self sign ssl laravel 11 - login with otp valid for 10 minutes. laravel 11 gaurds user and admin registration user and admin login multiauth postgresql 16 to postgresql 17 postgresql migration zabbix 7 how to install graylog on ubuntu 24.04 lts | step-by-step asp.net core mvc .net mvc network upload c# ssl integration sql server on ubuntu 22.04 lts mssql server ms sql server sql server user access in postgres mysql password change cent os linux configure replica kubernetes (k8s) install nginx load balancer install install and configure .net 8.0 in ubuntu 24.04 lts php in iis php with iis php tutorial chirags php tutorials chirags php tutorial chirags tutorial laravel 11 guards mongodb sharding metabase business analytics metabase ubuntu 24.04 koha 24.05 letsencrypt mongodb crud rocky linux laravel custom captcha laravel 11 captcha laravel captcha mongo dll php.ini debian 12 nginx apache nextcloud gitea in ubuntu git gitea npm error node js mysql ndb cluster mysql cluster ssl oracle login register logout in python debian windows shell batch file bat file time stamp date time shopping cart in laravel centos rhel swap memeory rhel 5.5
...