I am trying to use the migrate
function in Laravel 4
on OSX
. However, I am getting the following error:
Laravel requires the Mcrypt PHP extension.
As far as I understand, it's already enabled (see the image below).
What is wrong, and how can I fix it?
You need an all in one environment. You may use MAMP or XAMPP or any other tools. After installing one of these tools you will need to edit(create) your .bash_profile(Assuming that you use bash).
Or even simple and more professional you can use Laravel Homestead.
Here is a link to official documentation: http://laravel.com/docs/5.0/homestead
Also Jeffrey has a free tutorial about it: https://laracasts.com/series/laravel-5-fundamentals/episodes/2
I advice you to go with homestead because you will preinstall all of the following tools.
This solved it for me on my Linux Mint local enviroment https://askubuntu.com/questions/350942/cannot-get-mcrypt-for-php5
I needed to make a symlink to my /etc/php5/conf.d/mcrypt.ini file in the following folders /etc/php5/apache2/conf.d/mcrypt.ini and /etc/php5/cli/conf.d/mcrypt.ini
Using Ubuntu, just
did the trick for me. You don't need to restart Apache since you need to use PHP just from the CLI.
For those who still come here today:
Laravel does not need
mcrypt
extension anymore.mcrypt
is obsolete, the last update to libmcrypt was in 2007. Laravel 4.2 is obsolete too and has no more support. The best (=secure) solution is to update to Laravel >5.1 (there is no LTS before Laravel 5.2).Mcrypt was removed from Laravel in June 2015: https://github.com/laravel/framework/pull/9041
On OS X
Using MAMP
Enter the command
which php
in the terminal to see which version of PHP you are using. If it's not the PHP version from MAMP, the $PATH variable used by Bash will need to be updated.First, you should use command "cd /Applications/MAMP/bin/php" to check which php version from MAMP and take note of the version (eg, php5.6.7).
Once you know the version, you should edit the
~/.bash_profile
file (that is, the.bash_profile
that is in your home directory) and add an export line:Make sure that you replace php5.6.7 with the version of PHP that you have selected in MAMP.
Once the file has been saved, make sure that you close close your Terminal and open it again. Once that has been done, you will be using the PHP that ships with MAMP.
One way to easily find what the line should be that you need to put inside your
.bash_profile
is to run the following command inside your terminal:Copying and pasting those three lines into your terminal will correctly output the PHP version that has been selected inside the MAMP control panel.
Using Homebrew/MacPorts
Make sure that your
path
contains/usr/local/bin/
(Homebrew) or/opt/local/bin
(MacPorts) if you are using PHP that comes with either of these two package managers.Checking the PHP path with MacPorts
You can find the exact location of PHP using MacPorts with the following command:
Note that you should replace
php70
with the version of PHP that you have installed.Check the PHP path with Homebrew-php
Homebrew-php (https://github.com/Homebrew/homebrew-php) is a tap that has various different versions of PHP.
You can find the exact location of PHP using Homebrew with the following command:
Note that you should replace
php56
with the version of PHP that you have installed.In Ubuntu (PHP-FPM,Nginx)
After installing php5-mcrypt
you have to make a symlink to ini files in mods-available:
enable:
restart php5-fpm:
More detail