At first, I just merged the Laravel branch 7.0 into our 5.1 app. This led to a lot of merge conflicts that needed fixing. It was not a good move because we had mutated the original Laravel folder structure soo much that there were a lot of things that needed changing and new files the new version brought that we wouldn’t need.
So I resorted to using diffs to compare what had changed between the newer version and our current version. I did this using GitHub's built-in compare feature eg: https://github.com/laravel/laravel/compare/5.1...5.2 [↗].
With this, I got to see all the different changes that were made file by file and this allowed me to know what the change was for and how to translate that into our codebase. Sometimes this was a simple copy and paste, other times it was a rewrite to reflect what the improvement was for but then I couldn’t just copy and paste it.
Once that was done I ran composer to pull in all the other updated dependencies and then run through my tests.
There were also times when I found out that a package we relied on had been deprecated and not available for later versions of Laravel, in this case, I forked [↗] the original package and made any required updates, then referenced the forked repo in the composer file. I have currently started to replace these packages with newer ones as well but during the upgrade, the goal was to get everything working as is.
Between versions, some behaviors in Laravel changed. You won’t have a problem with most of these, but your output may not be what you expect. For example, the version of Carbon Library [↗] which Laravel uses to handle dates and time changed between version 1 and 2 and brought with it subtle changes that affected our DateTime formats. To help understand what behavioral changes each version had, the Laravel upgrade guide [↗] came in handy, this documented every piece of info regarding important behavior changes between versions.
Following this approach, I was able to get our app to version 7 of Laravel which was the latest at the time. Today we have new policies in place to migrate our tech stack frequently to prevent having to deal with an undertaking like I did.
Here is another article you might like 😊 How to turn a Git branch to a repository