Home > OS >  How can we downgrade Laravel dependencies from php 8 to php 7.4
How can we downgrade Laravel dependencies from php 8 to php 7.4

Time:06-15

I have this laravel project, but due the specific version of it's dependencies it need php 8 to run, but I need it to run with php 7.4, is there a way so that we can downgrade the dependencies?

     ....
     "require": {
        "php": "^8.0.2",
        "barryvdh/laravel-debugbar": "^3.6",
        "fruitcake/laravel-cors": "^2.0.5",
        "guzzlehttp/guzzle": "^7.2",
        "intervention/image": "^2.7",
        "laravel/framework": "^9.0",
        "laravel/sanctum": "^2.14",
        "laravel/tinker": "^2.7",
        "laravel/ui": "^3.4",
        "laravelcollective/html": "^6.3"
    },
    "require-dev": {
        "brianium/paratest": "^6.4",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^6.1",
        "pestphp/pest-plugin-laravel": "^1.2",
        "pestphp/pest-plugin-parallel": "^1.0",
        "phpunit/phpunit": "^9.5.10",
        "spatie/laravel-ignition": "^1.0"
    },
    ... 

Note: So far I could only found that manually searching for proper version compatible to php 7.4 and adjust it inside composer.json manually is an option.

CodePudding user response:

Laravel 9 works only on PHP 8, so you can't, unless you are up to downgrading Laravel version too. But installing newer PHP will be faster.

CodePudding user response:

Laravel 9 works on > php8 so you can't downgrade php version to 7.4 laravel support policy

CodePudding user response:

I recently did the same to one of my projects, so I did it like so

  1. Backup your project (just C/P it so you have a reserve if something goes wrong);
  2. Change the dependencies you need;
  3. Delete the vendor folder;
  4. I also deleted the composer.lock but I think you can actually skip this step;
  5. Run composer install;
  • Related