Home >Backend Development >PHP Tutorial >Laravel 'Mcrypt PHP extension' Error: How to Fix It When Using MAMP?

Laravel 'Mcrypt PHP extension' Error: How to Fix It When Using MAMP?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-13 09:20:11950browse

Laravel

Laravel: Troubleshooting "Mcrypt PHP extension" Error

Laravel requires the Mcrypt PHP extension, and an error message indicating its absence can be frustrating. This article addresses this issue faced while using the migrate function in Laravel 4 on OSX.

Despite the Mcrypt extension appearing enabled, there may still be issues. One potential culprit is the presence of MAMP, a popular development environment for PHP. MAMP uses its own PHP version, which may not be the one being used by Laravel.

To resolve this, verify the PHP version used by running "which php" in the terminal. If it's not from MAMP, edit or create ~/.bash_profile in your home directory (~) and add the following line:

export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH

Replace 'php5.4.10' with the appropriate PHP version used by MAMP. Restart the terminal and check the PHP version again. This should now point to MAMP's PHP.

If the above does not work, navigate to '/Applications/MAMP/bin/php', run 'ls' to determine the installed PHP version, and replace 'php5.4.10' in the command accordingly.

Once the MAMP PHP version is being used, retry the Laravel migrate function. It should now execute successfully.

The above is the detailed content of Laravel 'Mcrypt PHP extension' Error: How to Fix It When Using MAMP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn