Note that this was written Jan 9th, 2019, and I personally have not tested this since then. It's possible it will still work for your machine, but I can't guarantee it.
Based on some comments, it looks like someone may have had success with it Dec 22, 2020 too.
- This was tested with MAMP 5, but probably works with other versions
- This was tested with php 7.1.20 that was installed via MAMP interface
- You will need to use Homebrew for part of this - no, you won't need to use homebrew for your php or apache or anything. you'll still use MAMP. It's just used to install some things we'll need to compile pdo_dblib
Someone says you should ensure you have the latest xcode (or install it) with the command line tools.
I didn't check or run this, but I've had it installed somewhat recently. May as well run it
$ xcode-select ---install
You'll need to install these two things via homebrew:
$ brew install autoconf
$ brew install freetds
I don't think these 2 pecl commands are required probably... but I did run them during this process while messing around with things, and everything ended up working for me... so... let's run them just to be safe.
First command tells pecl where your MAMP's php.ini file is, and the second command installs PDO via pecl... because why not.
$ pecl config-set php_ini /Applications/MAMP/bin/php/php7.1.20/conf/php.ini
$ pecl install pdo
If not, alls you gotta do is add this towards the beginning of your $PATH:
/Applications/MAMP/bin/php/php7.1.20/bin
I use fish shell, so for me I just ran:
$ echo 'set -g fish_user_paths "/Applications/MAMP/bin/php/php7.1.20/bin" $fish_user_paths' >> ~/.config/fish/config.fish
For bash, you'd add something similar to your ~/.profile
or ~/.bash_profile
file:
export PATH="/Applications/MAMP/bin/php/php7.1.20/bin:$PATH"
Download php source from a mirror here (change the php version if yours is different):
http://us1.php.net/get/php-7.1.20.tar.gz/from/a/mirror
$ cd ~/Downloads
$ tar -zxf php-7.1.20.tar.gz
$ cd php-7.1.20/ext/pdo_dblib
$ phpize
### compile using MAMP's php config/version
$ ./configure --with-php-config=/Applications/MAMP/bin/php/php7.1.20/bin/php-config --with-pdo-dblib=/usr/local/
$ make
### hooray! if you got here without an error, it worked. Now, copy the compiled extension over to MAMP's extension dir.
$ cp modules/pdo_dblib.so /Applications/MAMP/bin/php/php7.1.20/lib/php/extensions/no-debug-non-zts-20160303/
Add this to your MAMP's web php.ini file. You will add it within the "Dynamic Modules" section of the file. You can open the file and edit it right through MAMP's GUI.
; add this line to MAMP's php.ini file
extension=pdo_dblib.so
Save and close - it'll ask you if you want to restart, say yes.
Here's a gif that may or may not work:
$ nano /Applications/MAMP/bin/php/php7.1.20/conf/php.ini
I came across some note that told me I should it OUTSITE the "Dynamic Extensions" block otherwise it may get overwritten... I have no clue how accurate that is, but I heed their warning.
So I put mine literally right above the Dynamic Extensions block like:
extension=pdo_dblib.so
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
$ php -m | grep pdo_dblib
You should see a line output with "pdo_dblib"! If you don't see it, then you might not have the MAMP cli set up on your $PATH in your shell.
MAMP has a way to view the phpinfo(); output don't they? if not, throw <?php phpinfo();
into a php file on your mamp's site and hit it in your browser.
This was pretty helpful, although wouldn't work for MAMP: https://github.com/BellevueCollege/public-docs/blob/master/PHP/configure-mssql-pdodblib-mac.md
@jschroed91 Did you run the commands with native PHP 7.x installed? The difference in your and my outcomes seems to be what you had natively on the computer at the time, at least some of them. That's a typical problem with people trying to get old software to work; one person's dependencies end up having different results when run because of newer software at the time.
I haven't found a solution to this other than running the PHP framework's built-in php server command (bin/console server:start in my case, with Symfony), and I had to uninstall brew PHP 5.6 due to composer getting stuck on it no matter what I did with brew or .zshrc or PATH or aliases or anything... I'm still scratching my head at this, though I'm assuming compiling old PHP 5.6 library dependencies, and maybe even re-compiling PHP 5.6 right along with it, would solve it, but that seems like a bigger gamble.
My biggest concern with getting old software to work on newer computers is ending up downgrading software on the computer that other things use.