1 | initial version |
The process of linking Laravel 7 with Microsoft SQL Server involves the following steps:
Install the PHP SQL Server driver by running the following command:
sudo apt-get install php7.4-sybase
Configure the database connection settings in the .env
file. An example configuration for Microsoft SQL Server is:
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=1433
DB_DATABASE=mydatabase
DB_USERNAME=myusername
DB_PASSWORD=mypassword
Install the microsoft/mssql-server-linux
package via Composer by running the following command:
composer require microsoft/mssql-server-linux
Add the following line in the config/database.php
file under 'default' => env('DB_CONNECTION', 'mysql'),
:
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'prefix' => '',
],
Run php artisan migrate
command to migrate the database tables.
Run the application and the database configuration should be working correctly with Microsoft SQL Server.
Note: Ensure that the SQL Server driver is enabled in your php.ini
file.