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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-10 03:47:14 +0000
Seen: 17 times
Last updated: Jun 10 '23
Can CakePHP be utilized with Oracle as the Database?
What is the method for placing parentheses in column names when creating a table using an SQL query?
How can I generate the most recent SonarQube version incorporating an integrated database?
How to analyze SQL using Python?
How can larger BLOBs be compressed without being inlined?
How can ADOMD.NET be used to deploy UDFs (User defined functions) to SSAS?
How can APIs be accessed in SSIS (Microsoft SQL Server Integration Services)?
What are the other options for scripting in Powershell besides filesystemobject?