I have some legacy Laravel 4.2 projects running on PHP 7.1, and PHP 7.1 is no longer supported. (https://twitter.com/krakjoe/status/1201010799034195968?s=12) and then I decided to upgrade them to latest PHP 7.4
Laravel 4.2 requires mcrypt extension which is deprecated in PHP 7.1 and removed in PHP 7.2.
Laravel 4.2 has a release for PHP 7, and you can install mcrypt for ≥ 7.2 by PECL.
Step 1: Update Laravel to 4.2.22
Taylor has published a release for PHP 7 compatibility. Update your Laravel to 4.2.22 https://github.com/laravel/framework/releases/tag/v4.2.22
Step 2: Check your code compatibility
First you must be sure about your Laravel 4.2 code is compatible with PHP 7.4. You can check PHP change logs.
Step 3: Disable deprecated errors (optional)
Add the line below to your
app/config/app.php because you will get deprecated errors for mcrypt. It might not be a good idea but we are already trying to run some deprecated code consciously. Alternatively you can install https://github.com/tomgrohl/laravel4-php71-encrypter package.
error_reporting(E_ALL ^ E_DEPRECATED);
Step 4: Install and enable mcrypt extension
Install mcrypt extension on your PHP server with PECL.
$ sudo pecl install mcrypt
Step 5: Test it!
Now, it might be ready but it’s better you test it again. Then you’re ready to run your legacy Laravel 4.2 code on latest PHP 7.4 and get all updates including security ones.