AbdulBazith's avatar

How to upgrade laravel version from 6 to 10

hello guys iam using an online student exam application and i have done that application 3 years back while developing the version is Laravel Framework 6.20.44 currently i need to update that version in live cpanel. currenlty my cpanel php version is 7.4

First let me post my config/app. php


 'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Arr' => Illuminate\Support\Arr::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
        'Bus' => Illuminate\Support\Facades\Bus::class,
        'Cache' => Illuminate\Support\Facades\Cache::class,
        'Config' => Illuminate\Support\Facades\Config::class,
        'Cookie' => Illuminate\Support\Facades\Cookie::class,
        'Crypt' => Illuminate\Support\Facades\Crypt::class,
        'DB' => Illuminate\Support\Facades\DB::class,
        'Eloquent' => Illuminate\Database\Eloquent\Model::class,
        'Event' => Illuminate\Support\Facades\Event::class,
        'File' => Illuminate\Support\Facades\File::class,
        'Gate' => Illuminate\Support\Facades\Gate::class,
        'Hash' => Illuminate\Support\Facades\Hash::class,
        'Lang' => Illuminate\Support\Facades\Lang::class,
        'Log' => Illuminate\Support\Facades\Log::class,
        'Mail' => Illuminate\Support\Facades\Mail::class,
        'Notification' => Illuminate\Support\Facades\Notification::class,
        'Password' => Illuminate\Support\Facades\Password::class,
        'Queue' => Illuminate\Support\Facades\Queue::class,
        'Redirect' => Illuminate\Support\Facades\Redirect::class,
        'Redis' => Illuminate\Support\Facades\Redis::class,
        'Request' => Illuminate\Support\Facades\Request::class,
        'Response' => Illuminate\Support\Facades\Response::class,
        'Route' => Illuminate\Support\Facades\Route::class,
        'Schema' => Illuminate\Support\Facades\Schema::class,
        'Session' => Illuminate\Support\Facades\Session::class,
        'Storage' => Illuminate\Support\Facades\Storage::class,
        'Str' => Illuminate\Support\Str::class,
        'URL' => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View' => Illuminate\Support\Facades\View::class,

        // Input 
        'Input' => Illuminate\Support\Facades\Input::class,
        
        //sweet alert
        'Alert' => UxWeb\SweetAlert\SweetAlert::class,
        //Pdf
        'PDF' => Barryvdh\DomPDF\Facade::class,
        //Image Upload
        'Image' => Intervention\Image\Facades\Image::class,
        'DataTables' => Yajra\DataTables\Facades\DataTables::class,
        'Alert' => RealRashid\SweetAlert\Facades\Alert::class,
        
    ],


this is my composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2",
        "barryvdh/laravel-dompdf": "^0.8.6",
        "fideloper/proxy": "^4.0",
        "filp/whoops": "^2.7",
        "intervention/image": "^2.5",
        "laravel/framework": "^6.2",
        "laravel/tinker": "^2.0",
        "realrashid/sweet-alert": "^3.1",
        "spatie/laravel-permission": "^3.11",
        "uxweb/sweet-alert": "^2.0",
        "yajra/laravel-datatables-buttons": "^4.0",
        "yajra/laravel-datatables-editor": "^1.19",
        "yajra/laravel-datatables-fractal": "^1.5",
        "yajra/laravel-datatables-html": "^4.22",
        "yajra/laravel-datatables-oracle": "^9.8"
    },
    "require-dev": {
        "facade/ignition": "^1.4",
        "fzaninotto/faker": "^1.4",
        "laravel/ui": "^1.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0"
    },
    "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"
        ]
    }
}


and my file structure in app folder itself all my model files will be present.

Now how i need to upgrade this application. what i did is just gave composer update but i think no change when i check again php artisan --version it showing the old 6.20 version only. what are the changes i need to do to upgrade my laravel application to current version kindly some one help. updating php version in the cpanel that i can do it. but this laravel version how to upgrade?

0 likes
9 replies
jlrdw's avatar

You have to go through each upgrade guide.

Or use laravel shift.

Edit:

I suggest just creating a new laravel 10 app and work at migrating you M-V-C and custom classes over, will probably be easier. I have done similar, took a few hours with some breaks.

Snapey's avatar

moving multiple versions is often quicker and easier to install a fresh copy of the framework and copy your controllers, models, providers, routes etc to the new project.

Other than that, follow the guides. 6>7, 7>8 etc etc

there is a guide for each version if you switch the docs to the next version. Not forgetting that at some point you need to swap to php 8.1 or 8.2

AbdulBazith's avatar

@snapey @jlrdw understood your answer. but in older version the model files are just inside the app folder. but in current version in app folder there is a model folder and inside that those files are present. so if i download a new application current version and copy controllers, models, providers, routes. then i have almost 20 controllers so in each controller do i need to change the path for the model? and i have installed many packages so in the new project do i need to install all those packages? and just i tried an attempt of downloading new project and i started installing auth require laravel/ui but it saying me install npm and its not working.

so whats my final doubt is if i download a new project

  1. do i need to install all the packages i used in my application?
  2. do i need to change any config files? any routing changes as because the model files are inside model folder

kindly reply this guys

Snapey's avatar

@AbdulBazith

  1. Yes
  2. Yes you may need to make config changes but this has nothing to do with routes or models.

Models can stay where they are. There is no need to move them if you don't want.

martinbean's avatar

@AbdulBazith You’re better off upgrading incrementally, and fixing any issues as and when they arrive. You will also find out which packages will need upgrading, rather than trying to jump from 6 to 10 and then finding out half of your code needs re-factoring any way, and a number of packages are no longer compatible or have changed dramatically since their Laravel 6-compatible versions.

jlrdw's avatar

@AbdulBazith

but in older version the model files are just inside the app folder.

Fix the namespace as needed.

Just FYI, these type of upgrades have been discussed here in detail in past post.

Please or to participate in this conversation.