Back

Next week I have to start an update of a Laravel API written with version 7 to version 11. I'm thinking of creating a new project then porting over the code then updating what's needed. Think it might be the less painful action.

What say you fellow Laravel Devs? Is there a better approach I'm missing?

5

535

  • No matching results...
  • Searching...

/ 1000

I personally will do the same approach. However at work we used laravelshift.com

to do the heavy lifting (core, dependencies, syntax, break changes, etc) and it worked out really well. Now I just need to rewrite old code to the new fashion.

1

47

Ooh. Great shout! Definitely going to look at this. How did I not know about this?!

11

I agree with @hygotran, use shift if you can if not port over your business logic to a new app, depends on the complexity and the dependencies as well and how good your tests are.

1

83

Nice. I gotta look at Shift properly 👍

15

We used both Shift and the new project approach on different projects. Shift is great when the old project uses a lot of deprecated or broken methods, but it does not update the project's architecture to match Laravel 11's new structure (which is not a problem at all, in fact).

So, if your API is mostly constituted of simple controllers & models, a new installation would be as easy as Shifting, with the benefit of continuing with an up-to-date project architecture.

On a side note, I'd like to add that migrating an old project to a new installation is a great way to review the project's code, giving more insights on what may need to be reworked.

1

72

Your last paragraph is a brilliant shout. With the codebase being a few years old, it could do with a good review to see what can be improved.

As for the complexity of the project as a whole, it's fairly straightforward with simple models and controllers along with quite a few jobs that Laravel Horizon keeps an eye on. It uses the laravel-permission package from Spatie which will need updating but that's about the most complicated part. It might be a good project for me to use as my first go with Shift...🤔

25

No need you can just work with same code and set the path according to the new one recently i have migrated laravel 5 to laravel 11

1

98

Can you give an example or explain more? I'm not picturing how this works.

Thanks!

81

API Platform is now available for Laravel. It may not meet your needs, but you can still take a look.

110