DatsunBing
DatsunBing

Reputation: 9076

Steps for upgrading Laravel and PHP

I have a Laravel application that has been running since mid 2018. PHP is currently version 7.2.5 and Laravel is 5.6.22. I need to upgrade PHP to either 7.4 or 8.0, and Laravel to either 6 LTS, or 8.

As far as I can see, I have two options:

  1. Upgrade PHP to the new version, then incrementally upgrade Laravel from 5.6.22 to 6 LTS (or 8), testing each version as I go; or
  2. Upgrade both PHP and Laravel to their new versions, and do one round of testing

My initial thought was to use method 1, reading the Laravel notes for each release and tailoring my testing efforts as I go. But upon upgrading PHP to 7.4, Laravel started to fail somewhere deep in the library, so I guess V 5.6.22 does not work with PHP 7.4

Is there a standard approach to this problem? (Note that, sadly, I don't have automated unit tests).

Upvotes: 3

Views: 3753

Answers (1)

matiaslauriti
matiaslauriti

Reputation: 8100

This happened to me when I started working with Laravel, I started with Laravel 5.3 and my team had to upgrade it to 5.4, 5.5, 5.6 and 5.7 (then I left haha).

What we ended up doing was:

  1. First upgrade PHP, as it is the mostly certain that it will not cause any issue. I recommend you to upgrade to 8.0
  2. What we had done to upgrade was having tests. Previously we did not have, so we learn how to test and we reach a coverage of 90%, so we were extremely good at it and advancing fast on it.
  3. Once you have the tests, you can start migrating version by version. Because you are on 5.6, you could directly upgrade to 6 or 8, so you can follow the guide to upgrade from 5.8 to 6 or 7 to 8. It is easy to upgrade, the important stuff is related to packages mostly.

These are the tips and personal experience I can share with you. It is 100% important to have tests, else it will be a pain for you as you will not be 100% sure if something broke.

Upvotes: 1

Related Questions