Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect MSSQL in Laravel homestead?

I am trying to connect with a MSSQL database using laravel homestead. It always throws the exception:

PDOException in Connector.php line 55: could not find driver.

I've seen a lot of people talking about FreeTDS and Sybase drivers, but I can't seem to figure out what I need to enable laravel/php access to MSSQL databases from a Linux Web Server running the Laravel Homestead Vagrant box.

like image 980
AmitChaudhary Avatar asked Dec 11 '22 17:12

AmitChaudhary


1 Answers

I did lots of R&D for resolving this issue. Finally found the solution:

Laravel vagrant is using php 7. For mssql support we have to enable the relevant sybase driver for linux :

To Enable MSSQL Support for PHP 7:

First, ssh into your box vagrant ssh from the Homestead folder.

Command : vagrant ssh

Install the Sybase package for enabling the support for PDO and Mssql.

Command : sudo apt-get install php7.0-sybase

then run php -m on the ssh to make sure pdo_dblib is enabled.

All Done!!!! Cheers

like image 93
2 revs, 2 users 82% Avatar answered Jan 07 '23 07:01

2 revs, 2 users 82%