Skip to content

Instantly share code, notes, and snippets.

@queval-j
Created May 4, 2022 08:37
Show Gist options
  • Save queval-j/040128a4f307d0765fb08020dd47a2b8 to your computer and use it in GitHub Desktop.
Save queval-j/040128a4f307d0765fb08020dd47a2b8 to your computer and use it in GitHub Desktop.
Install PHP SQLSRV for Mac M1 (ARM64)
# 1) Follow documentation
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15
## a) Instal unixodbc and tools
```bash
$> brew install autoconf automake libtool
$> brew install unixodbc
```
## b) Install msodbc
```bash
$> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$> brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
$> brew update
$> HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18
```
# 2) Install with pecl
```bash
$> sudo CXXFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.10/include/" LDFLAGS="-L/opt/homebrew/lib/" /Applications/MAMP/bin/php/php7.4.21/bin/pecl install sqlsrv
$> sudo CXXFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.10/include/" LDFLAGS="-L/opt/homebrew/lib/" /Applications/MAMP/bin/php/php7.4.21/bin/pecl install pdo_sqlsrv
```
# 3) Update php.ini
extension=sqlsrv.so
extension=pdo_sqlsrv.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment