coryj
coryj

Reputation: 1255

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

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.

Upvotes: 48

Views: 95806

Answers (10)

Eric Norcross
Eric Norcross

Reputation: 4306

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.

Upvotes: 0

Deinumite
Deinumite

Reputation: 4019

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.

Upvotes: 40

James Paterson
James Paterson

Reputation: 2890

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.

Upvotes: 1

darronz
darronz

Reputation: 903

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

Upvotes: 20

Sophy
Sophy

Reputation: 9275

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.

Upvotes: 66

Rahul Prasad
Rahul Prasad

Reputation: 8222

Try sudo php5enmod mcrypt && sudo service apache2 restart

Upvotes: 28

user1108579
user1108579

Reputation: 2063

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

Upvotes: 0

Kris
Kris

Reputation: 1

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.

Upvotes: 0

duality_
duality_

Reputation: 18756

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!

Upvotes: 2

Andrew
Andrew

Reputation: 12809

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

Upvotes: 1

Related Questions