I have inherited a very messy Laravel 4.2 / Angular app - it has an inconsistent, sometimes surprising API; there are no tests; controller are fat and full of procedural code; models are being used more like repositories with special-purpose queries, and none of Eloquent's features are being utilised.
My preference is to do a complete rewrite to 5.4 and not copy a single line of the 4.2 app code into the new app, but I will need to continue to support and maintain the 4.2 app until end of life. My fear is that the current 4.2 app will fall out of step with the developing 5.4 version.
Does anyone here have any similar experience and thoughts they can share?
I've migrated 4.2 apps to 5.x before - some of them were terrible. In general, I prefer to migrate the code 'as is' and refactor it rather than do a re-write. With old horrible code you are never sure if you've missed some weird side-effect or 'bug-that-is-a-feature' when you're re-writing it.
If it's JS heavy you might be able to use the new Dusk tests on the side to write some tests of the system so you know you've not broken too much :-). See the 'utility bill' example for how you can use it for instance :
@ohffs Thanks for your response; I understand what you're saying about migrating the code into the new app; but it is so bad... it is so difficult and time-consuming to grok the current code nevermind making a necessary change!
I am not an Angular expert, but I suspect that it also follows a similar pattern as the Laravel code.
I'm currently migrating an old 4.2 app (with no tests) to 5.4.
I'm taking @ohffs method of migrating most of the code and re-writing the payments part, as it's now going to be using Spark instead of using Paypal (which was a nasty way to do it)
I am a big fan of writing-off (pun somewhat intended) old crappy code.
Instead of doing a re-write of old to new code redo the entire system diagram. Change the Models, add Repositories, Middleware, ServiceProviders etc. to make it current and work
A) How you would want it to and more importantly
B) Be nicer to the poor sod who has to read your code in the future
PS. Those pesky feature-bugs are the sort of thing your new code SHOULD miss but tests pick up on.
@meath I'm also migrating a c100k line php 4 app to laravel - it's a whole world of weird, misleading, buggy, awfulness. I started out thinking 'I'll just re-write it - it's too awful' but realised it was a terrible mistake after a month or so.
There's just so much strangeness tied up in old code that you miss when you're reading it and thinking 'Oh, it's just getting that thing from the db and adding one to it'. Then you notice your new code isn't showing quite the same result as the original because you hadn't spotted there was a global variable, or some bit of hidden magic or a method name subtly didn't match what the thing actually did.