how to upgrade laravel 6 to 7

Viewed 14126

i am trying to upgrade laravel 6 to 7, i got an error.

 our requirements could not be resolved to an installable set of
 packages.

   Problem 1
     - Conclusion: remove laravel/framework v6.0.3
     - Conclusion: don't install laravel/framework v6.0.3
     - laravel/ui 2.x-dev requires illuminate/console ^7.0 -> satisfiable by illuminate/console[7.x-dev, v7.0.0],
 laravel/framework[7.x-dev].
     - laravel/ui v2.0.0 requires illuminate/console ^7.0 -> satisfiable by illuminate/console[7.x-dev, v7.0.0],
 laravel/framework[7.x-dev].
     - Can only install one of: laravel/framework[7.x-dev, v6.0.3].
     - don't install illuminate/console 7.x-dev|don't install laravel/framework v6.0.3
     - don't install illuminate/console v7.0.0|don't install laravel/framework v6.0.3
     - Installation request for laravel/framework (locked at v6.0.3, required as ^6.0) -> satisfiable by laravel/framework[v6.0.3].
     - Installation request for laravel/ui ^2.0 -> satisfiable by laravel/ui[2.x-dev, v2.0.0].
7 Answers

Just follow the documentation, you must have installed php7.2.5

Update your laravel/framework dependency to ^7.0 in your composer.json file.

In addition, update your nunomaduro/collision dependency to ^4.1,

phpunit/phpunit dependency to ^8.5,

facade/ignition to> `^2.0

After that as next step.

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; // add this line

public function report(Throwable $exception); // replace Exception with Throwable
public function render($request, Throwable $exception); // replace Exception with Throwable

after that run

composer update

Update The following packages

"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5",

"laravel/ui": "^2.0",

"facade/ignition": "^2.0",

"laravel/framework": "^7.0",

for More clarity go to Guide

If Handle.php file error Check out Solution

As per Laravel Documentation to upgrade from laravel 6 to laravel 7

Update your laravel/framework dependency to ^7.0 in your composer.json file. In addition, update your nunomaduro/collision dependency to ^4.1, phpunit/phpunit dependency to ^8.5, and facade/ignition to `^2.0.

and then run composer update in your terminal

composer update

https://laravel.com/docs/7.x/upgrade

If you are get problems with this make sure you read ahead to this section and make the required changes. I found I HAD to make the changes in composer.json to get it to work. From the command line it just kept getting in a twist:

Authentication

Scaffolding Likelihood Of Impact: High

All authentication scaffolding has been moved to the laravel/ui repository. If you are using Laravel's authentication scaffolding, you should install the ^2.0 release of this package and the package should be installed in all environments. If you were previously including this package in the require-dev portion of your application's composer.json file, you should move it to the require section:

composer require laravel/ui "^2.0"

I'm working on an existing code and it was like this on version 5.8 in /app/Exceptions/Handler.php:

 public function report(Exception $exception)
{
    parent::report($exception);
}

I changed use Exception; to use Throwable; and made this change

 public function report(Throwable $exception)
{
    parent::report($exception);
}

and it worked after changing every Exception to Throwable and updating all dependencies and language versions.

Related