Laravel requires the Mcrypt PHP extension

后端 未结 22 1964
生来不讨喜
生来不讨喜 2020-11-22 07:59

I am trying to use the migrate function in Laravel 4 on OSX. However, I am getting the following error:

Laravel requir         


        
相关标签:
22条回答
  • 2020-11-22 08:42

    OSX with brew

    $ brew install mcrypt php70-mcrypt
    

    I am running PHP 7.0.x, so change "php70" to your version, if you are using a different version.
    As stated in other answers, you can see your php version with $ php -v.

    0 讨论(0)
  • 2020-11-22 08:44

    The web enabled extensions and command line enabled extensions can differ. 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.

    OSX

    I have heard of people on OSX running in to problems due to the terminal pointing to the native PHP shipped with OSX. You should instead update your bash profile to include the actual path to your PHP. Something like this (I don't actually use OSX so this might not be 100%):

    export PATH=/usr/local/php5/bin:$PATH
    

    Ubuntu

    On earlier versions of Ubuntu (prior to 14.04) when you run sudo apt-get install php5-mcrypt it doesn't actually install the extension into the mods-available. You'll need to symlink it.

    sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
    

    On all Ubuntu versions you'll need to enable the mod once it's installed. You can do that with php5enmod.

    sudo php5enmod mcrypt
    sudo service apache2 restart
    

    NOTES

    • PHP 7.1 deprecated mcrypt and 7.2 has removed the mcrypt extension entirely
    • Laravel 5.1 and later removed the need for mcrypt
    0 讨论(0)
  • 2020-11-22 08:44

    My OS is Yosemite.

    I resolve this issue, by finding configuration paths:

    php --ini
    

    Example output:

    Configuration File (php.ini) Path: /usr/local/etc/php/5.5
    Loaded Configuration File:         /usr/local/etc/php/5.5/php.ini
    Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
    Additional .ini files parsed:      (none)
    

    Next steps:

    1. Rename or Delete php55 ini file
    2. Create symlink
    3. Restart Apache server

    Commands:

    mv /usr/local/etc/php/5.5/php.ini /usr/local/etc/php/5.5/php.ini.default
    ln -s /etc/php.ini /usr/local/etc/php/5.5/php.ini
    sudo apachectl restart
    

    Then you can check your php modules via:

    php -m
    
    0 讨论(0)
  • 2020-11-22 08:44

    sudo php install mcrypt

    sudo php5enmod mcrypt

    0 讨论(0)
提交回复
热议问题