PHPackages                             techscope/laravel-sqlserver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. techscope/laravel-sqlserver

ActiveLibrary[Database &amp; ORM](/categories/database)

techscope/laravel-sqlserver
===========================

Use ODBC to connect with your SQL Server instances from Laravel 5+

202.1k9[4 issues](https://github.com/techscope/laravel-sqlserver/issues)PHP

Since Feb 7Pushed 7y ago3 watchersCompare

[ Source](https://github.com/techscope/laravel-sqlserver)[ Packagist](https://packagist.org/packages/techscope/laravel-sqlserver)[ RSS](/packages/techscope-laravel-sqlserver/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-sqlserver
=================

[](#laravel-sqlserver)

Use ODBC to connect with your SQL Server instances from Laravel 5+.

This package allows you to use the OFFICIAL Microsoft SQL Server ODBC driver to connect to a Microsoft SQL Server database.

Disclaimer: all Bash commands you will see here are examples for RHEL/CentOS Yum package manager. If you would like to help make these docs more friendly with other distros, please make sure to either submit a pull request on the README or open an issue with additional commands specifying which distro you are using and I'll then update the README docs.

Dependencies
------------

[](#dependencies)

### UnixODBC

[](#unixodbc)

```
sudo yum install -y unixodbc
```

### PHP's ODBC PDO driver

[](#phps-odbc-pdo-driver)

```
sudo yum install -y php-odbc
```

### Microsoft's SQL Server Driver

[](#microsofts-sql-server-driver)

You can find specific instructions for your distro here:

Package Installation
--------------------

[](#package-installation)

Install with composer

```
composer require techscope/laravel-sqlserver:dev-master
```

Add the Service Provider to config/app.php

```
TechScope\SqlServer\SqlServerServiceProvider::class
```

Make sure to update your config/database.php file

```
'domdb' => [
            'driver'        => 'sqlsrv',
            'odbc_driver'   => '{ODBC Driver 13 for SQL Server}',
            'host'          => env('DB_HOST', 'localhost'),
            'database'      => env('DB_DATABASE', 'forge'),
            'username'      => env('DB_USERNAME', 'forge'),
            'password'      => env('DB_PASSWORD', ''),
            'port'          => env('DB_PORT', '1433'),
            'TrustServerCertificate' => 'yes'
        ],
```

**IMPORTANT NOTES:**

- `driver` should be set to `sqlsrv`. This uses the preexisting SQL Server grammar that ships with Laravel.
- `odbc_driver` should be the name of the ODBC Driver as it appears in `/etc/odbcinst.ini`. Example:

```
[ODBC Driver 13 for SQL Server]
