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?
The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+. The mcrypt extension is included in PHP 5.4 through PHP 7.1.
You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!
To install the mcrypt php extension, do this: sudo apt-get install php5-mcrypt. and restart the server. sudo service apache2 restart. By the way, this might be off-topic, but let’s be honest: Laravel is a wonderful thing, but the install instructions are ..
Run php -m in your terminal and check to see if mcrypt is listed. If it's not then check where the command line is loading your php.ini file from by running php --ini from your terminal. In this php.ini file you can enable the extension.
The easiest way is to download MAMP and let him install everything for us, like PHP, Apache and MySql, something that you’ll need for sure if you’re intended to build something with Laravel. Also, remember to install Composer to manage all the dependency of PHP and help you out a lot with Laravel, but not only. And here comes the pain!
The easiest way is to download MAMP and let him install everything for us, like PHP, Apache and MySql, something that you’ll need for sure if you’re intended to build something with Laravel. Also, remember to install Composer to manage all the dependency of PHP and help you out a lot with Laravel, but not only.
Do you have MAMP installed?
Use which php
in the terminal to see which version of PHP you are using.
If it's not the PHP version from MAMP, you should edit or add .bash_profile
in the user's home directory, that is : cd ~
In .bash_profile
, add following line:
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
Edited: First you should use command cd /Applications/MAMP/bin/php
to check which PHP version from MAMP you are using and then replace with the PHP version above.
Then restart
the terminal to see which PHP you are using now.
And it should be working now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With