Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade laravel 5.5 to laravel 10?

Tags:

php

laravel

I wanted to update from Laravel 5.5 to 10. My php version is 8.1.5 but facing many problems to update directly here. Especially ,

 requires php ^7.3 -> your php version (8.1.5) does not satisfy that requirement.

if it can't be updated directly, what steps should be taken? I have attached my Composer json file below.

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=7.0.0",
    "barryvdh/laravel-dompdf": "^0.8.4",
    "fideloper/proxy": "~3.3",
    "gloudemans/shoppingcart": "^2.5",
    "intervention/image": "^2.4",
    "laravel/framework": "10",
    "laravel/tinker": "~1.0",
    "niklasravnsborg/laravel-pdf": "^3.1",
    "shipu/php-aamarpay-payment": "^1.0",
    "milon/barcode": "^5.2",
    "yajra/laravel-datatables": "1.5"
  },
  "require-dev": {
    "filp/whoops": "~2.0",
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "~1.0",
    "phpunit/phpunit": "~6.0",
    "symfony/thanks": "^1.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
  },
  "extra": {
    "laravel": {
      "dont-discover": [
        "laravel/dusk"
      ]
    }
  }
}

I wanted to take version 8 first, then 9 and 10 one by one, but mPDF caused the most problems.

Please help me I am beginner.

like image 768
Rakib Hasan Avatar asked Oct 24 '25 16:10

Rakib Hasan


1 Answers

Laravel provides a full and understandable documentation on how to update Laravel. You could upgrade directly from Laravel 5.5.0 to Laravel 10.x, but it could create a lot of errors that will be difficult to understand and to solve. I suggest you follow this process and upgrade your project to each version before by following the versionning order, you start by 5.5.0 to 5.6, then 5.6 to 5.7, 5.7 to 5.8, 5.8 to 6.x, 6.x to 7.x, 7.x to 8.x, 8.x to 9.x and 9.x to 10.x

Here is the documentation from where you should start. Just to be clear I am not saying you cannot upgrad directly from Laravel 5.5.0 to Laravel 10. I've already did it with Laravel 5.7 to Laravel 9.x. I don't remember exactly every step, but I remember that I did this

  1. I created a Laravel 9.x project, installed the dependencies I wanted in it.
  2. I made a copy of the project in Laravel 5.7 (In case for backup)
  3. I took the composer.json from the Laravel 9.x project and I copied it in the copy of the Laravel 5.7 project
  4. Then I ran the command composer update in the copy of the project in Laravel 5.7

After that there were a lot of errors from Laravel framework components, I solved them all one by one, it took me an afternoon. I would have avoid all this error solving if I would have followed every upgrade documentation and followed the versionning in order.

If you are curious here is my project in Laravel 9.x and you can see the fork attached to it is in Laravel 5.7 and it works perfectly

like image 144
Dolotboy Avatar answered Oct 26 '25 06:10

Dolotboy