Installing Brew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing MSSQL Tools
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql17 mssql-tools
If you installed this formula with the registration option (default), you'll need to manually remove [ODBC Driver 17 for SQL Server] section from odbcinst.ini after the formula is uninstalled. This can be done by executing the following command:
$ odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
Install dependencies:
$ brew install autoconf automake libtool
Install PHP Drivers for MSSQL
$ sudo pecl install sqlsrv
$ sudo pecl install pdo_sqlsrv
In case your MSSQL .so
files didn't load properly, you can find the exact location of the files with following command:
$ find . -name pdo_sqlsrv.so -print
$ find . -name sqlsrv.so -print
In my case I got the following path for the files. Now
/usr/local/lib/php/pecl/20170718/sqlsrv.so
/usr/local/lib/php/pecl/20170718/pdo_sqlsrv.so
Next, just copy the files to your respective PHP Version lib directory:
cp /usr/local/lib/php/pecl/20170718/sqlsrv.so /usr/local/Cellar/[email protected]/7.2.13/lib/php/20170718/
cp /usr/local/lib/php/pecl/20170718/pdo_sqlsrv.so /usr/local/Cellar/[email protected]/7.2.13/lib/php/20170718/
Then make sure the following extensions is loaded in php.ini
extension="pdo_sqlsrv.so"
extension="sqlsrv.so"
Use php -m | grep sqlsrv
to check the extensions is loaded properly.
php -m | grep sqlsrv
pdo_sqlsrv
sqlsrv
Y have two PHP versions (7.4 & 8) This works for PHP 8 but not for the other version. Any idea? Thanks !!