jlrdw's avatar
Level 75

Update upgrade laravel then framework (guide)

Some folks don't realize there are two main repositories for Laravel.

  • Laravel = app
  • Framework = vendor stuff

Also there is updating and upgrading.

  • Update = replacing some things, not all
  • Upgrade = Replace all excluding your custom code (MVC)

In other words your models, view, and controller code.

To do a complete upgrade from 5.8* to 6.* requires you to upgrade laravel first.

Special note

Many updates / upgrades in laravel are optional, so read over the entire upgrade guide.

6.* changed, 6.0 still used filp/whoops, but the later 6.* uses ignition.

So a guess is you are going for the latest 6.* not 6.0

See these images:

First image

Shows how some files are the same, others have changes.

Last two images

Are just examples of changed files. The idea is to upgrade your current version with these changes.

For example look at resources\js\bootstrap.js in above image, see the difference. This is what's meant to upgrade laravel first. Same for any changed files, upgrade your laravel to the new versions.

I use winmerge compare tool, but you use whatever or however you need, just completely upgrade laravel first. Normally the upgrade guide handles everything, but a compare tool doesn't hurt.

Next check server requirements, php ver, etc.

After all laravel is upgraded, now run composer update which will upgrade the framework.

Note any added packages you will have to handle updates on those. If you have added packages, you will know how to handle this.

Note:

In the above I compared ver 5.8.35 with 6.5.2

Also Important

The 6.* has new scaffolding for authentication, so see:

https://laravel.com/docs/6.x/authentication All about the new Laravel's laravel/ui package.

Edit: scroll down to last answer concerning Laravel 8.

0 likes
11 replies
Sinnbeck's avatar

Very nice guide @jlrdw

It would be great if we could pin posts 📍

2 likes
jlrdw's avatar
Level 75

Added note on updating minor versions:

I just updated from 6.0 to 6.5.2. And even here there are many changed files in laravel: Most won't affect an update, but see these images.

Alt image

Alt image

Most changes were minor, like reversing use statements. The docs so far only shows:

quote

Upgrading To 6.0 From 5.8

unquote

updating from a 6.* to a higher 6.* version also needs to be looked at for changes.. But after completely updating laravel and then and only then running composer update, all worked well.

Also note you have to get the composer file changes between minor versions also, lines like

"laravel/framework": "^6.0",

//// changed to

"laravel/framework": "^6.2",

I only added this guide, because some folks just run composer update only, but that's not enough, update laravel first then the framework.

Always read the docs also on requirements and always backup in case an update goes wrong.

kensmithzzz's avatar

I did the laravel/laravel compare today and got up to date. It will be a lot easier now in the future now that I'm up to date.

Thanks for the tips on upgrading, and here is a recommendation if you're running on Linux and need a tool for these kinds of compares. Beyond Compare by Scooter Software is Linux compatible (Windows and Mac too). It's a fantastic tool for this kind of job.

jlrdw's avatar
Level 75

@kensmithzzz thanks and also thanks for sharing the Linux tool.

Also version 8 notes:

I found it easier to "reverse upgrade" to version 8, meaning:

Do a new install, do the Auth scaffold, etc.

Then I used my compare tool to copy over my models, views, controllers, custom helper folder and my service folder.

I then adjusted the models. Since now there is a Models folder, of course it's optional.

But doing it this way actually went pretty fast.

Note if version 8 you setup Auth with one of these:

  • Jetstream
  • Setup using Fortify only
  • Laravel UI
  • Manually as always

Each way of setting up Authentication is covered tn the documentation, note Jetstream has docs:

https://jetstream.laravel.com/1.x/introduction.html

Fortify see the readme:

https://github.com/laravel/fortify/blob/1.x/README.md

UI:

https://github.com/laravel/ui/blob/3.x/README.md

Manually:

Covered in security chapter in Laravel documentation.

But that is just the way I chose to do the upgrade.

Snapey's avatar

I don't recommend upgrading laravel, just upgrade the framework, as per the upgrade guide,

jlrdw's avatar
Level 75

@snapey you have made me confused there, the upgrade guide is updates / upgrades in laravel, prior to upgrading the framework. In the upgrade guide and the documentation you are not updating the framework.

I would like to ask @Jeffreyway to confirm this, as I don't think I am reading the upgrade guide wrong.

For example this part in laravel 7

https://laravel.com/docs/7.x/upgrade#symfony-5-related-upgrades

There you are updating / upgrading something in laravel, not the framework.

The way you answered, newcomers will think all they have to do is run composer update, which is not the case.

This guide this meant for upgrading to a new version not inside an existing version.

just upgrade the framework, as per the upgrade guide,

That is not correct.

Yes a 6.* to a 6.* newer then yes just composer update

But a 6.* to 7.* just updating the framework is not going to work.

Snapey's avatar

@jlrdw Note;

Update the following dependencies in your composer.json file:

guzzlehttp/guzzle to ^7.0.1
facade/ignition to ^2.3.6
laravel/framework to ^8.0
laravel/ui to ^3.0
nunomaduro/collision to ^5.0
phpunit/phpunit to ^9.0

You will note that you are advised to up the version number of Laravel/Framework. This is the upgrade

Other dependencies are updated also.

Nothing in your project need be updated unless the upgrade guide advises it.

jlrdw's avatar
Level 75

But it does advise you

Symfony 5 Related Upgrades Likelihood Of Impact: High

Laravel 7 utilizes the 5.x series of the Symfony components. Some minor changes to your application are required to accommodate this upgrade.

First, the report, render, shouldReport, and renderForConsole 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 shouldReport(Throwable $exception);
public function render($request, Throwable $exception);
public function renderForConsole($output, Throwable $exception);

That for example has to be manually updated in laravel, running composer update does not fix that.

also from @TaylorOtwell

Miscellaneous

We also encourage you to view the changes in the laravel/laravel GitHub repository. While many of these changes are not required, you may wish to keep these files in sync with your application. Some of these changes will be covered in this upgrade guide, but others, such as changes to configuration files or comments, will not be. You can easily view the changes with the GitHub comparison tool and choose which updates are important to you.

I encourage folks to completely upgrade laravel prior to upgrading the framework but of course like you said some of the things are optional.

I also updated original to reflect some things are optional. But I strongly recommend to update all anyway.

1 like
Snapey's avatar

@jlrdw

No one is saying that you just run composer update. You follow the upgrade guide.

But for instance, in 7 to 8, removing the $namespace property from the Route service provider breaks all routes in an upgrading application. An unnecessary step.

The upgrade instructions should be complete and if not you should send in some PRs to the upgrade guide, not write your own.

1 like
Miel's avatar

This was very helpful @jlrdw ! I started with version 5.1 and did only the necessary updates from the upgrade guide and that was fine for me at the time. Since 5.8 i do the full upgrade as you advised. Another benefit for me with this method is that i get to know Laravel a bit better. I work with PhpStorm where you can easily compare files so it's a bit more work, but that's fine by me. So thanks!

Please or to participate in this conversation.