There are various threads about this issue happening with earlier versions of MAMP, but most of those threads are dated back to 2014 and now it's 2016 with MAMP Pro having version 4.
I need Mcrypt for a legacy codebase / framework. With MAMP Pro 4 you can change PHP version per host. In this instance I'm running 5.5.38.
Framework outputs just text "Mcrypt PHP extension required." – and when using phpinfo() it's clear that Mcrypt is not loaded as there is no section for Mcrypt but this is listed under Configure Command:
--with-mcrypt=shared,/Applications/MAMP/Library'
On MAMP Pro 4 under File > Edit Template > PHP (php.ini) > 5.5.38 there is this line:
extension=mcrypt.so
So everything seems to be in order and clearly they have intended it to work out-of-the-box – or after an version upgrade, as in my case MAMP Pro 3.4 > 4.0.6.
But why doesn't this work?
NOTE! This problem is not with CLI PHP, but Apache's host PHP.
It seems they have messed up with PHP ini files before (2y ago), resulting in a similar problem, promising to deliver a fix soon: Mcrypt with Mamp Pro on Mac OS X Yosemite 10.10
Additional info:
MacOS 10.11.6 El Capitan
which mcrypt
/usr/local/bin/mcrypt
locate mcrypt.ini
/usr/local/etc/php/5.4/conf.d/ext-mcrypt.ini
/usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini
I had a similar issue with MAMP 4.1 (454). I was installing Joomla on top of MAMP, but Joomla reported that mcrypt was missing.
The problem was in the php.ini file. Specifically, in /Applications/MAMP/bin/php/php7.1.0/conf/php.ini on line 422 was:
However, the extensions directory did not have a "no-debug-non-zts-20151012" directory. Instead it had a "no-debug-non-zts-20160303" directory.
The fix was to edit that line to change "no-debug-non-zts-20151012" to "no-debug-non-zts-20160303" and make the same change in two other places in the php.ini file. After making that change and restarting the MAMP servers Joomla could see mcrypt and mcrypt appeared on the phpInfo page.
The diff for the change is: