# PHP Extensions sqlsrv & pdo_sqlsrv on Apple M1 ARM64 ## Install brew If you do not already have it, install brew as follows: ```bash /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ``` ## Install the GNU make tools ```bash brew install autoconf automake libtool ``` ## Install PHP If you do not already have it, install php as follows: ```bash brew tap brew tap homebrew/core brew install php@8.1 ``` You probably need to set the path (and place it in your .zshrc or .profile): ```bash export PATH="/opt/homebrew/bin:$PATH" ``` ## Install Microsoft ODBC 18 ```bash brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18 ``` ## Install the PHP Drivers ```bash sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install sqlsrv sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv ``` ### References: - https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16#installing-on-macos - https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16