Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 730
coryj Avatar asked Sep 18 '12 15:09

coryj


People also ask

How do I enable Mcrypt?

You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!

What is Mcrypt PHP extension required?

The Mcrypt extension is an interface to encrypt the Mcrypt cryptographic library. This extension enables PHP code to use mcrypt. Earlier this extension was available in PHP. But for PHP 7.2+ and higher, the mcrypt extension is available only in the PECL repository.

Is Mcrypt deprecated?

ext/mcrypt ¶The mcrypt extension has been abandonware for nearly a decade now, and was also fairly complex to use. It has therefore been deprecated in favour of OpenSSL, where it will be removed from the core and into PECL in PHP 7.2.


2 Answers

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.

like image 177
Sophy Avatar answered Oct 13 '22 01:10

Sophy


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.

like image 44
Deinumite Avatar answered Oct 13 '22 00:10

Deinumite