V
V
Victoria Kabishova2021-11-07 17:32:53
PHP
Victoria Kabishova, 2021-11-07 17:32:53

What am I not adding to the .env file when connecting sqlsrv?

Hello, I want to connect a database using sqlsrv, I understand that this is written in the .env file, but I get the following error:
6187e32f91b7e743003167.png
Here is the database.php file:

'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

here is the .env file:
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=1433
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=

What am I doing wrong? Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-11-07
@Parsifal31017

You need to install sqlsrv on the system:

pecl install sqlsrv \
    && echo "extension=sqlsrv.so" >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-sqlsrv.ini

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question