MAC: find active php.ini, add mcrypt extension to php7.2.10, verify

Find your active php.ini:
php -i | grep ‘Configuration File’
php –info | grep php.ini

Add extension to your php.ini (anywhere):
extension=mcrypt.so

Add mcrypt.so to php7.2.10
Credit: https://stackoverflow.com/questions/42504777/enable-mcrypt-using-mamp

“Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.10/bin
It might be different in your case. Now run the below command with sudo”

sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1

Could also need to have done:
brew install autoconf mcrypt

Now check that it’s active via one of these:

if(function_exists('mcrypt_encrypt')) {
    echo "mcrypt is loaded!<br />";
} else {
    echo "mcrypt isn't loaded!<br />";
}

if(extension_loaded('mcrypt')) {
    echo "mcrypt extension is loaded!<br />";
} else {
    echo "mcrypt extension isn't loaded!<br />";
}

or on the command line:
php -r “if(function_exists(‘mcrypt_encrypt’)){echo ‘exists’;}else{echo ‘nope’;}”

Credit: https://stackoverflow.com/questions/25476889/how-to-check-if-mcrypt-extension-exists-on-php

Leave a Reply

You must be logged in to post a comment.