Search code examples
pdoxamppsqlsrvapple-silicon

macOS Ventura (Apple Silicon M2) + XAMPP + PDO SQL SERVER: PDO Exception - Could not find driver


I hope you guys are doing well.

I used for many years Windows Server + XAMPP for php development, specifically, using the SQL Server Database.

Recently, I chanced to a brand new MacBook Pro M2, which is my first experience using macOS.

Right now, I am struggling to make my installation detect the pdo_sqlsrv driver. The phpinfo file doesn't show the sql driver listed. Besides, all the connection attempts shows PDO exception: Could not find driver. enter image description here

I followed the instructions listed on the following article: https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16

php -v command returns:

PHP 8.1.12 (cli) (built: Oct 30 2022 12:39:49) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.12, Copyright (c) Zend Technologies with Zend OPcache v8.1.12, Copyright (c), by Zend Technologies

sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install sqlsrv shows:

pecl/sqlsrv is already installed and is the same as the released version 5.10.1 install failed

And I also used the sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv command:

pecl/pdo_sqlsrv is already installed and is the same as the released version 5.10.1 install failed

I added the following lines inside the /Application/XAMPP/etc/httpd.conf file:

<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>

Inside manager-osx, the server events tab isn't show any kind of error or warning. Do you guys have any idea of what am I missing, or doing wrong? enter image description here enter image description here


Solution

  • I was able to finish the installation using the following link: https://github.com/microsoft/msphpsql/blob/master/Linux-mac-install.md#installing-the-drivers-on-macos