Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jlrdw's avatar
Level 75

Laravel 4.2 and PHP 7

Does anyone know if version 4.2 works on PHP 7 or not Thanks.

0 likes
22 replies
jlrdw's avatar
Level 75

@Ruffles so the new PHP error and exception handling is fine in ver 4.2?

davorminchorov's avatar

It shouldn't break anything because errors can be caught in PHP 7, compared to them being fatal errors in 5.6!

mfjordvald's avatar

PHP 7 and Laravel 4.2 doesn't work perfectly as Laravel enforces Exception classes being passed around and PHP 7 now uses Throwable as the base exception. The biggest problems with this is that when an error happens it won't be reported properly.

3 likes
sebdd's avatar

Bump! Anyone know a nice way to get proper error handling in 4.2 running on PHP7?

jlrdw's avatar
Level 75

Let's move you to top, can anyone help here, I have one project in 4.2 I would would love to keep there.

ohffs's avatar

@jlrdw can you bring up a VM with php7 and try it? Looks like other people are trying and indeed hitting the Exception/Throwable issues : https://github.com/laravel/framework/issues/11329 . At a guess they're focused on finishing up 5.2 just now - maybe 4.2 will get some attention after that, though given the policy is only to support for a year it might not :-/ I've got some stuff using 4.1 so I'm not upgrading it to 7.

jadz0r's avatar

I don't think there's going to be any further 4.2 support.

As a dirty, dirty workaround, I've pushed a fork of the 4.2.17 release tag up to my own repository.

This forked master branch changes the \Exception requirement to be \Throwable.

My fork: https://github.com/jadz/laravel-framework-4.2.18-php7

composer.json updates:

"repositories": [
        {
            "type": "git",
            "url": "https://github.com/jadz/laravel-framework-4.2.18-php7"
        }
    ],
 "require": {
        "laravel/framework": "dev-master"
}

You might need to remove your bootstrap/compiled.php version before running a composer update.

Feel free to submit any pull requests.

Note - I'm certain there is a more elegant way of achieving this, but for my purposes this quick and dirty fix will get me over the line while I work on upgrading our codebase to make a 5.2 transition easier.

bashy's avatar

4.2 works fine for me on php7.0.1

benharold's avatar

@jadz0r is spot-on. If you throw exceptions in your app you're likely to run into Error in exception handler.

jadz0r's avatar

@jlrdw The fork will only work with PHP7.

I've been running it stable for over 2 months now.

clayjar's avatar

Your app written on Laravel 4.2 may NOT be 100% compatible with PHP 7.0. We have an app that interfaces with a mobile device and authenticates using HMAC. I think it may have something to do with the differing key sizes and some negative(?) changes related to PHP packages related to encryption. Please note that I'm NOT saying that L4.2 by itself lacks full compatibility.

brayanrastelli's avatar

@jadz0r how do I handle dependencies by using your fork? I've tried switching to it, but when I run composer update I get this:

    - Conclusion: don't install laravel/framework dev-master
    - aws/aws-sdk-php-laravel 1.0.0 requires laravel/framework 4.0.* -> satisfiable by laravel/framework[4.0.x-dev].```
jlrdw's avatar
Level 75

@brayanrastelli as of now there is actually a updated ver of laravel 4.2 out, 4.2.20 php 5.6 through php 7 compatible.

1 like

Please or to participate in this conversation.