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

BeginnerSoul's avatar

SQLSRV connection

Hello I am trying to connect to my SQL Server (sqlsrv) but it is not that easy as in the tutorials it seems so. I am using this application for developing and testing https://laragon.org/ and I added php 7.4.19 version. My laravel version is 9.27.0.

When I check in the phpinfo then I see the pdo_sqlsrv and sqrsrv extensions loaded so they are active.

My env file:

DB_CONNECTION=sqlsrv
DB_HOST=IP address\Instance
DB_PORT=1433
DB_DATABASE=MyDatabase
DB_USERNAME=MyUsername
DB_PASSWORD=",My,Strong,Password,"

However I get this error message:

  could not find driver (SQL: select * from sys.sysobjects where id = object_id(migrations) and xtype in ('U', 'V'))

P.S.: I loaded the 7.4 extensions which can be downloaded on the microsoft webpage.

What I am doing wrong then? Thanks in advance the answers.

0 likes
1 reply
BeginnerSoul's avatar

Ah ok, now I get it why didn't work on my pc because I had multiple php version and in the environment variable I had php 8.1 version instead 7.4 and I needed to downgrade to laravel 8 to work with sql server. (because the specific hosting doesn't have on php 8.1 the sqlsrv extension).

Please or to participate in this conversation.