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

93,929

Solution 1

You need to enable it in your php.ini file as well and probably restart Apache.

In php.ini you will find ;mcrypt.so and remove the ; from it.

Or, if it's not in there, just add mcrypt.so somewhere.

Also the salt option has been deprecated as of PHP 7.0.0. It is now preferred to simply use the salt that is generated by default.

Solution 2

Ubuntu or any Debian based Linux users can install the required package with apt-get:

sudo apt-get install php5-mcrypt

Remember to restart the web server afterwards:

sudo service apache2 restart

If it still doesn't work, try to link the configuration file to the appropriate configuration folder for the web server. Thanks to dave1010 for this hint in the comments.

sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/   # for Apache
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/       # for CLI

And again, restart the web server:

sudo service apache2 restart

Perhaps, if not working yet, you need also the line showed by @RahulPrasad, with php5enmod mcrypt.

Solution 3

Try sudo php5enmod mcrypt && sudo service apache2 restart

Solution 4

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

Solution 5

You don't have the mcrypt PHP extension installed.

For a Mac, I followed these instructions: mcrypt on Mac 10.7 or 10.8.

They look like a lot, but it's not, it's very easy to follow in it works!

Share:
93,929

Related videos on Youtube

coryj
Author by

coryj

Web Developer, Student @ Rutgers

Updated on February 05, 2020

Comments

  • coryj
    coryj over 4 years

    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 in terminal command php -m either, if that matters. I'm running Mountaion Lion with macs native web server.

    • Amit Erandole
      Amit Erandole over 11 years
      You need to recompile php again
  • coryj
    coryj over 11 years
    Didn't seem to work.. Found this line of code code[mcrypt] ; For more information about mcrypt settings see php.net/mcrypt-module-open ; Directory where to load mcrypt algorithms ; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt) ;mcrypt.algorithms_dir= ; Directory where to load mcrypt modes ; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt) ;mcrypt.modes_dir= code
  • coryj
    coryj over 11 years
    This is what finally helped me if anyone else browsing has this same issue. Thank you guys for your quick responses! => coolestguyplanettech.com/…
  • Deinumite
    Deinumite over 11 years
    @coryjacik It depends on how you've compiled mcrypt, I should have specified that probably.
  • dualed
    dualed over 11 years
    @coryjacik Thanks for the link, I followed that guide too. But even though on my system, autoconf was already installed, I had to sudo ln -s /Developer/usr/share/autoconf /usr/share/ to get /usr/share/phpize working.
  • Carlton
    Carlton almost 11 years
    Did the apt-get part and that my web server config was reloaded but needed a restart like Sophy mentions
  • aymericbeaumet
    aymericbeaumet over 10 years
    The PO should definitely use these solution to solve his problem... brew is the way to install packages on Mac OS X.
  • dave1010
    dave1010 over 10 years
    For some reason on Ubuntu, PHP wasn't picking up the mcrypt.ini. This fixed it: sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ ; sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/
  • theycallmemorty
    theycallmemorty about 10 years
    This doesnt work for me... Error: No available formula for php55
  • leemes
    leemes about 10 years
    @dave1010 Yeah that did it, thank you very much!! But why the same command twice?
  • dave1010
    dave1010 about 10 years
    @leemes good spot. It should have been going into the apache2 and cli directories (or whatever SAPIs you use): sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ ; sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/
  • leemes
    leemes about 10 years
    @dave1010 Ah okay. I guess almost nobody noticed that mistake because most people use Apache :)
  • leemes
    leemes about 10 years
    @dave1010 I hope it's okay that I copied this information into the answer so that future readers can spot it quickly.
  • frederickf
    frederickf over 9 years
    For me the mcrypt.ini what at /etc/php5/mods-available/mcrypt.ini. I'm using Ubuntu 14.04 LTS and PHP 5.5.9-1ubuntu4.3.
  • Peter Krauss
    Peter Krauss over 9 years
    mcrypt.so?? phpinfo() say that my php.ini is ` /etc/php5/apache2/php.ini`, and there are NO string "mcrypt.so"!
  • Peter Krauss
    Peter Krauss over 9 years
    Good, now it is working (and after @Sophy procedures)!
  • Jimmy Knoot
    Jimmy Knoot about 9 years
    It actually does make sense, the PHP you use at the command line (cli) can use a different php.ini than the PHP your webserver uses, you should make a phpinfo file and check what the webserver is using.
  • ppostma1
    ppostma1 almost 9 years
    new versions of debian/ubuntu are easier (and require) apt-get install php5-mcyrpt;, php5enmod mcrypt;, service php5-fpm restart
  • hash
    hash almost 9 years
    This is the correct way to install mcrypt and also remember after run this command brew search mcrypt you want to install mcrypt using brew install php56-mcrypt
  • user110857
    user110857 over 8 years
    @JimmyKnoot Thanks, I wasn't aware.
  • slevin
    slevin over 6 years
    By the way , mcrypt_create_iv is DEPRECATED in PHP 7.1.0. See http://php.net/manual/en/function.mcrypt-create-iv.php
  • arthropod
    arthropod over 5 years
    For Debian 9 and PHP 7 the needed package is php7.0-mcrypt.