Search code examples
laravelmigrationlaravel-4mcrypt

Laravel Mcrypt error / Still not working after several attempts


Please bear with me here for a second. I am quite new to working with frameworks especially Laravel. However, I have seriously tried to set everything up using various tutorials and the documentation.

I am now using MAMP as my local server and a have installed laravel via composer.

However, in most of the tutorials people are using artisan commands in terminal to create migrations.

I always get the same error here even though I have already tried to download another php version and mcrypt and to set those things up in the terminal.

Is there maybe anything I have to do in MAMP?

I have already seen this question but I cant figure out which one of all these solutions fits my situation:

Laravel requires the Mcrypt PHP extension

I would be very glad if somebody could give me some ideas here.

Thanks.


Solution

  • You receiving Mcrypt not found error because your Mac terminal using system's PHP and unfortunately, Default PHP don't have the MyCrypt extension.

    How to enable Mcrypt:

    The easiest solution is, use the MAMP's PHP

    How to use MAMP?

    Simply edit ~/.profile (ie. open Terminal.app, type vim ~/.profile or nano ~/.profile) and add the following line to end of the file:

    export PATH=/Applications/MAMP/bin/php/php5.x.x/bin/:$PATH Note that you should replace x.x in php5.x.x with the MAMP Pro PHP version.

    My setting:

    in your terminal:

    nano /Users/anam/.bash_profile
                ^^^ your mac home directory
    

    I have placed the following code to my .bash_profile:

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