Mohamad Salahia
Mohamad Salahia

Reputation: 167

Upgrade Laravel project from 5.5 to latest version 8

I want to Upgrade my Laravel project from (5.5 to 8) what I will do for that. I didn't found any documents to upgrade from 5.5 to 8 just upgrade from 5.5 to 5.6 or from 7 to 8 maybe must upgrade the project step by step from 5.5 to 5.6 the from 5.6 to 5.7 then .... nutil 8 Thanks

composer.json(Laravel 5.5):

{
"name": "HomFolio",
"description": "Smart Property Investing",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=7.0.0",
    "ext-json": "*",
    "barryvdh/laravel-dompdf": "^0.8.1",
    "barryvdh/laravel-translation-manager": "dev-master",
    "fideloper/proxy": "~3.3",
    "intervention/image": "^2.4",
    "joedixon/laravel-translation": "^1.1",
    "laravel/framework": "5.5.*",
    "laravel/tinker": "~1.0",
    "stripe/stripe-php": "^4.7",
    "zizaco/entrust": "dev-master"
},
"require-dev": {
    "filp/whoops": "~2.0",
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "~1.0",
    "phpunit/phpunit": "~6.0",
    "xethron/migrations-generator": "^2.0"
},
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"extra": {
    "laravel": {
        "dont-discover": [
        ]
    }
},
"scripts": {
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate"
    ],
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover"
    ]
},
"config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
}
}

composer.json (Laravel 8):

{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
    "framework",
    "laravel"
],
"license": "MIT",
"require": {
    "php": "^7.2.5",
    "fideloper/proxy": "^4.2",
    "fruitcake/laravel-cors": "^1.0",
    "guzzlehttp/guzzle": "^6.3",
    "laravel/framework": "^7.0",
    "laravel/tinker": "^2.0"
},
"require-dev": {
    "facade/ignition": "^2.0",
    "fzaninotto/faker": "^1.9.1",
    "mockery/mockery": "^1.3.1",
    "nunomaduro/collision": "^4.1",
    "phpunit/phpunit": "^8.5"
},
"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
},
"extra": {
    "laravel": {
        "dont-discover": []
    }
},
"autoload": {
    "psr-4": {
        "App\\": "app/"
    },
    "classmap": [
        "database/seeds",
        "database/factories"
    ]
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate --ansi"
    ]
}
}

Upvotes: 13

Views: 29658

Answers (4)

saurabh kamble
saurabh kamble

Reputation: 1549

Adding to some missing steps to @Krina Mangukiya

  1. /bootstrap/environment.php :

    $dotenv = Dotenv\Dotenv::createImmutable(DIR.'/..'); $dotenv->load();

  2. The report and render methods of your application's App\Exceptions\Handler class should accept instances of the Throwable interface instead of Exception instances:

    use Throwable;

    public function report(Throwable $exception); public function render($request, Throwable $exception);

This answers have taken from stackoverflow only but would be go to have all issue answers in one place.

Upvotes: 0

Krina Mangukiya
Krina Mangukiya

Reputation: 426

You have to follow the steps given below:

  1. Copy the your current composer.json file.
  2. Now go here https://github.com/laravel-shift/laravel-8.x/blob/master/composer.json and copy composer.json file and replace with your existing composer.json file.
  3. Again go to https://github.com/laravel-shift/laravel-8.x/blob/master/app/Exceptions/Handler.php and copy the Handler.php file and go to app/exceptions/Handler.php replace Handler.php with your existing file.
  4. Run the command composer update.
  5. Check your old or your copied composer.json file and if packages have been added to it then you can add packages through this command composer require <package name>.
  6. Now, again run composer update command.

Upvotes: 17

P. K. Tharindu
P. K. Tharindu

Reputation: 2730

You going to have to upgrade iteratively I'm afraid.

If you have the budget, you can use a service like Laravel Shift to automate the upgrade.

Upvotes: 3

The Sammie
The Sammie

Reputation: 1248

Looks like upgrades are sequential. As of today, I have a laravel 5.7 project that I have to upgrade to Laravel 8 and this looks like the sequence I need to take. Upgrade sequence

Even when you opt for the highly recommended Laravel Shift, you have to pay for each upgrade as indicated in the picture below.

Upgrade pricing.

If you have budget, laravel shift looks like a quick and easy way to go through the upgrade(s)

Upvotes: 11

Related Questions