Mcrypt PHP extension required MAMP

How to fix „Mcrypt PHP extension required“ (MAMP)

Von am 08.11.2016

So you’ve updated your macOS to Sierra and you’re just php artisan serving your Laravel project and out of the blue you read from deep within your memories an uncomfortable wake-up call:

Mcrypt PHP extension required error

Mcrypt PHP extension required error

 

The well-known „Mcrypt PHP extension required“ error message awaits us.

There are different ways of approaching this. The problem is that your project requires the mcrypt library for internal uses and unfortunately doesn’t have it linked. It’s quite common to use your development environment’s PHP build, which you can individually configure to your needs – in this case we will be using MAMP as an example. You could start by finding out the current PHP version – execute php -v:

php version

Find out current php version

 

Seems like I’m using version 5.6.25, which is the integrated PHP build that comes with macOS Sierra and doesn’t have the mcrypt extension linked. We can confirm that by typing below command and getting an empty result:

Solution

First, select your preferred version from the MAMP control panel. Go to Preferences > PHP:

MAMP Preferences PHP version

MAMP Preferences PHP version

 

Then, we are going to link the php command to the current build of the MAMP development environment by writing the following source lines to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc):

You might need to manually source your profile:

And that’s that ! If you now type php -v, you can see the updated PHP version you just linked. Now php artisan serving your Laravel should work just fine – or at least not throw the Mcrypt requirement error anymore.

Hopefully this read helped you ! 🚴

 

The comments are closed.