Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ZetecVan's avatar

Upgrading a project. Best practices?

I have recently gone live with a Laravel 10 project. It was just before Livewire V3 was released so used V2, plus a couple of composer dependencies required V2 anyway. Now all the plugins can use V3, I have decided to upgrade everything.

I use Git and because the project is live, need to have a repo I can apply bugfixes to, so I can't really do a git checkout -b UpgradeBranch and attempt the upgrade in there.

I did find a post about cloning the repo into a new folder, deleting everything and 'rebuilding' it, and it linked to a Matt Stauffer blog post, but that's unavailable now, and it was a few years old as it was to upgrade from L4 to L5.

What are the best practices of performing an upgrade like this?

0 likes
6 replies
martinbean's avatar
Level 80

so I can't really do a git checkout -b UpgradeBranch and attempt the upgrade in there

@zetecvan Absolutely you can.

You create the branch. Do the upgrade. When you’re happy it’s working as It should, you can then merge that feature branch into your “main” branch.

ZetecVan's avatar

@martinbean Can you? I tried it earlier, checking out a new branch, then started the upgrades. Then I spotted an error in production, so switched back to main to checkout a hotfix branch, and composer.json had the upgraded versions in. That's when I thought 'Oh, I am doing this wrong'.

martinbean's avatar

@ZetecVan Yes. If you’ve updated your composer.json file and then installed different versions of packages—or different packages altogether—then those changes are specific to that branch.

When you switch branches, i.e. back to your “main” branch, you need to ensure you run composer install to re-install the packages and versions currently in use for that specific branch, and not the other branch you were working on.

ZetecVan's avatar

@martinbean That's what I thought. When I switched back to main I was expecting to see the v2 packages so I've clearly done something wrong. I'll have a play around tomorrow and see what it is. Thanks for your help.

ZetecVan's avatar

@martinbean I've come to it this morning, and everything has worked as expected. The only thing I did differently yesterday was commit the upgrade branch before switching. All is good. Thank you.

1 like

Please or to participate in this conversation.