Running Laravel 4.2 Project on PHP 7.3 or 7.4

Yavuz Selim Bilgin
Dec 1 · 1 min read

I have some legacy Laravel 4.2 projects running on PHP 7.1, and PHP 7.1 is no longer supported. ( 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

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 package.

# /app/config/app.php
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.

Yavuz Selim Bilgin

Written by

mühendis, yazılım geliştirici, internet, medya, bilgi güvenliği, tarih, uluslararası ilişkiler, dijital diplomasi, CTO @BilginPro

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade