can't find mcrypt => Call to undefined function Laravel\mcrypt_create_iv()

前端 未结 10 1784
刺人心
刺人心 2020-12-29 01:04

Trying to set up Laravel and keep getting hit with this error. I installed mcrypt through brew and it is located in /usr/local/Cellar. Any thoughts? .. It\'s not showing up

相关标签:
10条回答
  • 2020-12-29 01:38

    You may have installed mycrypt but not have the php_mcrypt module installed / enabled.

    0 讨论(0)
  • 2020-12-29 01:41

    Go to the CLI folder in your php instalation, and find php.ini in there and enable mcrypt. Terminal sometimes uses another php.ini, which is usually in the CLI folder.

    0 讨论(0)
  • 2020-12-29 01:41

    This is what finally worked for me:

    brew reinstall --with-homebrew-curl --with-httpd php56
    brew reinstall --build-from-source php56-mcrypt
    

    I also had to do sudo chmod 777 /usr/local/etc/php/5.6/conf.d because I got errors when the second brew reinstall tried to add the ext-mcrypt.ini to that directory.

    0 讨论(0)
  • 2020-12-29 01:43

    I installed php and mcrypt with Homebrew, but I still experienced this error after doing brew update a few times. I think my setup has just gotten a bit borked over time.

    It turns out my php was being configured from /private/etc/php.ini, not /usr/local/etc/php/5.4/php.ini as Homebrew recommends. Mcrypt is not even being included from /usr/local/etc/php/5.4/ext-mcrypt.ini which doesn't make a lot of sense considering php -i produces this for me:

    Configuration File (php.ini) Path => /usr/local/etc/php/5.4
    Loaded Configuration File => /usr/local/etc/php/5.4/php.ini
    Scan this dir for additional .ini files => /usr/local/etc/php/5.4/conf.d
    Additional .ini files parsed => /usr/local/etc/php/5.4/conf.d/ext-mcrypt.ini
    

    My solution:

    1. Edit /private/etc/php.ini as a superuser
    2. Add extension="/usr/local/Cellar/php54-mcrypt/5.4.28/mcrypt.so" and save
    3. Restart Apache with sudo apachectl restart
    0 讨论(0)
  • 2020-12-29 01:46

    You've installed mcrypt when you actually wanted the php56-mcrypt php module.

    You stated in your question that you can see mcrypt installed in /usr/local/Cellar and that you're using OSX. So, the easiest way to install the mcrypt PHP module on OSX using Homebrew is:

    // assuming you have php56
    brew install php56-mcrypt
    

    If homebrew can't find the correct package you may need to tap the PHP repositories found on GitHub:

    brew tap homebrew/dupes
    brew tap homebrew/versions
    brew tap homebrew/homebrew-php
    

    Now when you issue the command brew search mcrypt, you should see something like:

    libtomcrypt   mcrypt   php53-mcrypt   php54-mcrypt   php55-mcrypt   php56-mcrypt
    

    Several other posters have mentioned the need to edit your php.ini file. This will be unnecessary as homebrew will take care of activating the module for you. It places the configuration file at /usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini

    0 讨论(0)
  • 2020-12-29 01:51

    Just a note for people who have recently upgraded to PHP 7 - The MCRYPT library has been deprecated. If you upgraded to PHP 7 and are now seeing this error, that is why. You should switch to an alternative library, some alternatives are mentioned in this thread.

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