You Are Here: Home » How-To » Programming

How To Fix – Mcrypt PHP extension required in Laravel on Mac OS X (No MAMP)

By Debjit on October 1st, 2015 
Advertisement

Laravel PHP web framework requires certain libraries to function properly. One of these libraries is the mcrypt and the php-mcrypt (bridge between mcrypt and php). However, there is a good chance that you will run into issues while running Laravel if these libraries and the extensions are not properly installed.

When I got started with setting up Laravel on a Mac OS X Maverics development machine, i ran into this error which said: Mcrypt PHP extension required. This can be fixed easily - in two ways either by installing php54-mcrypt or the php55-mcrypt extension using homewbrew for mac or my manually compiling the php-mcrypt extension.

The development machine has the pre-installed PHP on OS X maverics and not the one from a third party package installer like MAMP.

Please note that, the recent OS X Update El Capitan has caused Homebrew installations to run into a permission issue. You might want to fix that before you continue.

Step 1: Install mcrypt for Mac OS X Maverics using homebrew - this command:

sudo brew install mcrypt

Just in case you get a brew error while running this command, this will be the cowardly refusing to sudo error from brew, fix it and try the above command again.

Step 2: Install php-mcrypt extension using brew (based on your php version php 5.4 or php 5.5:

sudo brew install php55-mcrypt

or

sudo brew install php54-mcrypt

If you get errors like brew no available formula, then you will have to build the mcrypt extension for php manually which is a really easy step.

After you are done with above steps, you should now no longer see the Mcrypt PHP extension required error and you are all set to start your Laravel development.

Some sample outputs:

Debjit-Sahas-Mac-mini:app debjit$ brew install mcrypt
==> Installing mcrypt dependency: mhash
==> Downloading https://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.t
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/mhash/0.9.9.9
==> make install
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/mhash.h
/usr/local/include is not writable.

You can try again using:
brew link mhash
==> Summary

If you encounter errors like the `brew link` step did not complete successfully or mcrypt.h not found then all you need to do is issue the following commands in your terminal:

sudo brew link mcrypt

if above does not work then try the following command:

sudo brew link --overwrite mcrypt

Once you restart Apache after following these steps, you will see the Laravel welcome message: You have arrived

Laravel Mcrypt Welcome Message

Laravel Mcrypt Welcome Message

 

Advertisement







How To Fix – Mcrypt PHP extension required in Laravel on Mac OS X (No MAMP) was originally published on Digitizor.com on June 29, 2014 - 1:02 am (Indian Standard Time)