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

molero's avatar

Laravel 4.2 php version

Hi, As I seen on documentation, Laravel 4.2 requires php 5.4 or higher. However recently I'm getting the following fatal error running my app on a server with php 5.4 installed: syntax error, unexpected 'finally' (T_STRING), expecting catch (T_CATCH).

The error points to "/Applications/MAMP/htdocs/directorio-landings/vendor/symfony/dependency-injection/ContainerBuilder.php", so i guess that this error appears with the lastests Symfony updates.

Is there a way to downgrade that components and still having laravel working on php 5.4?

The error disappears when I run the app on MAMP server with php 5.5.

Thanks!

0 likes
6 replies
tisuchi's avatar

@molero

Well.. I think you need to downgrade your dependencies manually in composer.json file. May be one by one bind the compatible package and then update your composer....

2 likes
molero's avatar

Thanks @tisuchi !

Yesterday I've been trying to downgrade Laravel until 4.1 version, but the problem persists.

I found that inside vendor/laravel/framework there is a composer.json with the dependencies, but dependency-injection doesn't appears.

"require": {
        "php": ">=5.4.0",
        "classpreloader/classpreloader": "~1.0.2",
        "d11wtq/boris": "~1.0",
        "ircmaxell/password-compat": "~1.0",
        "filp/whoops": "1.1.*",
        "jeremeamia/superclosure": "~1.0.1",
        "monolog/monolog": "~1.6",
        "nesbot/carbon": "~1.0",
        "patchwork/utf8": "~1.1",
        "phpseclib/phpseclib": "0.3.*",
        "predis/predis": "0.8.*",
        "stack/builder": "~1.0",
        "swiftmailer/swiftmailer": "~5.1",
        "symfony/browser-kit": "2.7.*",
        "symfony/console": "2.7.*",
        "symfony/css-selector": "2.7.*",
        "symfony/debug": "2.7.*",
        "symfony/dom-crawler": "2.7.*",
        "symfony/finder": "2.7.*",
        "symfony/http-foundation": "2.7.*",
        "symfony/http-kernel": "2.7.*",
        "symfony/process": "2.7.*",
        "symfony/routing": "2.7.*",
        "symfony/security-core": "2.7.*",
        "symfony/translation": "2.7.*"
}

However, inside vendor /symfony/dependency-injection i found this:

"require": {
        "php": ">=5.5.9"
 },

I'm afraid because I have a lot of projects to maintain with Laravel 4.2 and we work with a dedicated server that is not easy to upgrade.

Thanks!

Any help is welcome!

ohffs's avatar

Have you tried renaming your vendor folder then running composer install again? Just to see what it pulls in? I have a lot of old php 5.3 sites and got caught when I installed something via composer on a VM which had a slightly newer php.

Other than that - there was an update to L4.2 a few weeks ago to make it compatible with php 7, so I guess it's faintly possible that something snuck through.

molero's avatar

@ohffs I've tried to to create a new Laravel project and I found that the problem is with another dependency I'm using on this project. It's jonnyw/php-phantomjs that requires Symfony's dependency injection.

At least all my other Laravel projects are safe :)

I will still looking for the solution and will post here if i find it.

Thanks a lot!

ohffs's avatar

Ah - glad you figured it out :-) I find it a bit annoying when libraries bump up their php versions when there are still well supported older ones being widely used - I've seen quite a few now requiring php7 even though they aren't using anything specific that needs it :-/

molero's avatar
molero
OP
Best Answer
Level 1

Hi,

Finally the solution was to downgrade my installed php version to 5.4.45, rename the vendor folder and reinstall everything again.

Now it works :)

Thanks again for all responses!

1 like

Please or to participate in this conversation.