screwtape_mk's avatar

Upgrading from Laravel 8 to 12

Firstly apologies for a noob question however :

I'm upgrading my Laravel app from version 8 to 12. Rather than upgrading through each version, I’ve decided to start fresh with a new Laravel 12 installation and migrate my existing code to this new installation.

My plan is to copy over essential files from the Laravel 8 app — controllers, models, views, routes, and assets like CSS/JS etc. However, I’m unsure which other files I should migrate. For instance, I’ve noticed differences in the vendor folders and some discrepancies between the two projects' structures.

I'm also unclear about how to handle composer.json, autoload, and any other important considerations during this migration. Can you help clarify what I should keep in mind?

I will use this thread to also share any issues and troubleshoots hopefully it becomes a useful resource for others in a similar position.

0 likes
18 replies
screwtape_mk's avatar

These are the Steps I intend to follow:

Step By Step Process:

1.Move all files from the Old laravel App 2. Re-write the composer.json file in 12 by copying the relevant dependencies from 8 3. Run Composer update 4. Update .env file

screwtape_mk's avatar

I have now executed on these and here are some learnings:

  1. Ensure to move the right application files and not 'system files' for lack of a better word.
  2. I made the mistake of moving the bootstrap folder from the old application - this gave me errors
  3. Normally the files / folders to move are app, resources, public etc, ensure that you understand this well before moving files over
JussiMannisto's avatar

I don't recommend that. You'll probably run into issues either immediately or somewhere down the line.

Whether you upgrade the existing project structure or move everything to a fresh install, you need to read the upgrade guides to see what has changed. Laravel 8 is several years old, and later versions include breaking changes.

screwtape_mk's avatar

@JussiMannisto I agree, and looking back perhaps this wasn't the best idea i thought it was. However upgrading one version at a time has previously caused me issues that took an inordinate amount of time to resolve, so perhaps you can call it PTSD from that approach.

kevinbui's avatar

If you are upgrading a little side project, that might work.

Anything bigger than that, I suggest not to. Pls do one of the following:

  • Upgrading a version at a time using the upgrade guide. Laravel 8 is pretty mature, upgrading to higher version is not hard. OR
  • Use Laravel Shift. We gotta pay quite a bit of money, but this saves us so much time.
Snapey's avatar

Re-write the composer.json file in 12 by copying the relevant dependencies from 8 3

I would not do this. Write down the project's dependencies and require them once Laravel 12 is installed. This way you get compatible versions of packages and not ones that were compatible with 8.3

Snapey's avatar

@LeoCross however its not a good advert for your skills if you dont understand who is asking the question.

screwtape_mk's avatar

So I ended up upgrading one version at a time, the initial way i had suggested ended up giving me many troubles. I am now on Php 8 and Laravel 12. The one issue I am now experiencing is the following:

Call to undefined function str_limit()

According to meta ai I should replace this with since the function has been deprecated:

\Illuminate\Support\Str::limit

However there is just so many places in which the deprecated function appears

LeoCross's avatar

Hello, @snapey , How are you? I am running latest laravel project on my local using windows herd. I have following error when I run project on my local.

504 Gateway Time-out (my-project.test) nginx/1.25.2

Please help me if you have experience about this.

Snapey's avatar

@LeoCross Sorry I dont need to put up with Windows.

By the way,

  • dont call people out
  • dont hijack other completely unrelated questions
N1-San's avatar

hi @screwtape_mk i'm in a similar situation as you, i'm upgrading my project from laravel 7 to 12, from what i read in this thread, you had better experience upgrading one version at a time rather than directly upgrading to laravel 12, can you share what were the major challenges you faced when trying to upgrade directly to laravel 12.

Please or to participate in this conversation.