How to downgrade project from laravel 9 to laravel 8?

Viewed 66

my laravel 9 project composer.json file

"require": {
    "php": "^8.0.2",
    "guzzlehttp/guzzle": "^7.2",
    "intervention/image": "^2.7",
    "laravel/framework": "^9.19",
    "laravel/sanctum": "^3.0",
    "laravel/tinker": "^2.7"
},
"require-dev": {
    "fakerphp/faker": "^1.9.1",
    "laravel/breeze": "^1.12",
    "laravel/pint": "^1.0",
    "laravel/sail": "^1.0.1",
    "mockery/mockery": "^1.4.4",
    "nunomaduro/collision": "^6.1",
    "phpunit/phpunit": "^9.5.10",
    "spatie/laravel-ignition": "^1.0"
},

I have created new project using laravel 8 and new composer.json file

"require": {
    "php": "^7.3",
    "fideloper/proxy": "^4.2",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel/framework": "^8.0",
    "laravel/tinker": "^2.0"
},
"require-dev": {
    "facade/ignition": "^2.3.6",
    "fzaninotto/faker": "^1.9.1",
    "mockery/mockery": "^1.3.1",
    "nunomaduro/collision": "^5.0",
    "phpunit/phpunit": "^9.3"
},

I have moved all models, controller, database, resources and route files. But as you can see sanctum is not used in laravel 8. Thats why my project is not running. How can I solve this?

I am new to laravel framework. I have created few projects in laravel 9 only and its working fine. I dont know how I can use laravel 8 now to work on same projects. Also I cant even install npm in laravel 8, showing me error.

1 Answers

Update your composer.json file with the 8.0 version of laravel. Also, check if your desired laravel version requires a specific PHP version other than what you are already running.

"require": {
    "php": "^7.3",
    "fideloper/proxy": "^4.2",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel/framework": "^8.0",
    "laravel/tinker": "^2.0"
}

Now, delete your vendor folder and composer.lock file inside your project folder.

Here is the Laravel Upgrade Guide where you can verify the functions that need to be updated at the code level. But since we are downgrading, we need to remove the updated functions from the code if used any from the higher version.

Then, run the following command inside your project folder:

 composer install

Now, turn on the server and test if it is working as expected. If yes, then you have successfully downgraded your laravel version.

Hope it helps!!

Related