Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP7.1 and Laravel 5.3: Function mcrypt_get_iv_size() is deprecated

Tags:

php

laravel

I'm using Laravel 5.0 for all my projects. Yesterday, I've updated my PHP version from 7.0.x to version 7.1.0. Once updated, I tried opening my Laravel project and saw this message below:

ErrorException in Encrypter.php line 303: 
Function mcrypt_get_iv_size() is deprecated

in Encrypter.php line 303
at HandleExceptions->handleError('8192', 'Function mcrypt_get_iv_size() is deprecated', 'C:\wamp64\www\project1\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php', '303', array()) in Encrypter.php line 303

May I know how can I solve this ? Does using Laravel 5.3 solve the problem? I don't feel like updating my Laravel to 5.3 because it's a huge project and it will takes a long time to update. There are too much differences between these two versions. Lots of codes need to be modified.

Is there an easier way to solve this issue?

like image 563
nodeffect Avatar asked Dec 08 '16 03:12

nodeffect


2 Answers

This error occurs because you probably have something other than AES-256-CBC as your cipher in your config/app.php file that depends on the mcrypt extension. Perhaps you are using MCRYPT_RIJNDAEL_256 or MCRYPT_RIJNDAEL_128?

The best thing you can do without a full-blown Laravel upgrade is install the legacy encrypter and use it to update all your encrypted data to use the AES-256-CBC cipher which has been the default cipher since Laravel 5.1, I believe. Once you do this, you should be able to use PHP 7.1 for your Laravel application.

like image 179
Benjamin Kohl Avatar answered Nov 11 '22 16:11

Benjamin Kohl


Add this to the beginning of the config/app.php:

error_reporting(E_ALL ^ E_DEPRECATED);

Source: https://stackoverflow.com/a/42515505/225790

like image 31
Debiprasad Avatar answered Nov 11 '22 15:11

Debiprasad