I am trying to connect to MS SQL database to pull some data and import to my MySQL DB. I am using the latest version Laravel 9 with Laravel Sail. Here are the steps I took
sail artisan sail:publish
to publish Docker and then in the Docker folder under 8.1 (PHP version I use) in Dockerfile i added the following
# Add repository ODBC and Install the Microsoft ODBC driver for SQL Server
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
&& ACCEPT_EULA=Y apt-get install -y mssql-tools18 \
&& apt-get install -y unixodbc-dev
# Install the PHP drivers for Microsoft SQL Server
RUN curl -O https://pear.php.net/go-pear.phar \
&& php go-pear.phar
RUN pecl install sqlsrv \
&& pecl install pdo_sqlsrv \
&& 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 \
&& phpenmod -v 8.1 sqlsrv pdo_sqlsrv
Then I ran sail build --no-cache
and everything finished with no error
But when I try to connect to the DB I get could not find driver
error
Note: I also have all the DB variables set in my .env file