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

michalis's avatar

Problems installing sql server using laravel sail

I've been using laravel sail recently, adding sql server as part of the sail container. This was working fine in the previous version of sail (sail v1.13.1 and php v8.0)

I am having trouble making it work with the newer versions of sail and php (sail v1.13.5 and php v8.1)

the docker image builds successfully but when I visit the site url, it gives me a network error:

message: "could not find driver (SQL: select * from [campaigns] order by [created_at] desc)",…}
exception: "Illuminate\Database\QueryException"
file: "/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php"
line: 712

im not sure what I am doing wrong, can anyone help? this is the addition I made to the dockerfile:

RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
0 likes
7 replies
michalis's avatar

@Sinnbeck check if sqlsrv is loaded? if yes, then I dont seem to be able to find any mention of it in phpinfo()

Im not sure why its not loading though

mateusgalasso@yahoo.com.br's avatar

Worked for me sudo su printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini exit sudo phpenmod sqlsrv pdo_sqlsrv

2 likes

Please or to participate in this conversation.