I have an ancient version of 2.10.16. I tried to upgrade it to 3.x with Upgrade tool found in GitHub. It didn’t do the work as there are many errors and version.txt shows it is still version 2.10.16. Is there a good way to upgrade current version straight to 4.x?
Any migration from 2.x to 3.x or 4.x is going to involve substantial work on your part. The migration tools can do pieces of the work, but there is much (most specifically, everything related to the ORM) that needs manual attention.
It’s going to be a painful process. I’ve been going through it for 6 months as I can. No method has went untouched, so depending on how big your app is, that might put some scale on it for you. Things like authentication and authorization are completely different, setup and configured completely different as well. So for me I found myself trashing everything I had in version 2 and completely redoing it all in version 4. I never could get authorization tools to do what I needed and ended up not using them at all in version 4 and writing my own authorization wrapper in about day after spending 5 days trying to get Cake4’s authorization tools to work. Everything around the ORM will change, but to be honest, for me that’s been less painful than everything else that’s changed.
In such a case , it might be easier starting a brand new project and working your models, views, etc over, yes basically a recode.
I had similar situation a while back in a laravel app, it just took a little time.
The best of luck with this.
I used the tools to upgrade my old app from 1.3 to 3.x, then also baked everything based on my database, and used WinMerge to help me to blend the two. The result still needed lots of work, but it got me a good ways along the path of keeping my custom business logic while incorporating the newer application style. I’m not sure it’s a good option for everyone, but it worked for me.
I have some template files (.ctp). And atleast one of them is exactly the same as in previous version. Is this one of the files that I have to 100% rewrite as CakePHP 3.x compatible?
This is what I ended up doing. At first I tried using the upgrade tools to upgrade to 3 and then the plan was 4 after that. That’s the way the docs say to do it. However, after looking at the changes even between 3 and 4 and the upgrade not going to well even to 3… I just basically started from scratch using 4 and moved my old code over method by method and reworking it where needed. It’s a long process and I’m still working on it.
I’m not sure I completely understand your question. Template files are the files that shouldn’t have to change a whole lot. The Form helper has changed a lot so depending on what you doing there, that might need some work. The main thing is the file extenstion (.ctp) will change to .php. All my were throwing errors until I changed that.
Oh, and also your references to your variables. Under version 2 we referenced arrays. Now, by default, you’ll be referencing entity objects. So you code in your view might change from something like:
How big is your application and how much time it would approximately take to upgrade?
And question: I am quite stuck with my upgrade from 2.x. Is there a step by step guide for upgrade tool (like what to do after running these commands?)? Or is it “easier” just to download new CakePHP 4.x version and start moving my stuff there and rewrite the code?
I have about 50 or so controllers across the app and custom plugins we’ve written over the years that are all having to be upgraded. Probably about the same number of models, maybe a few more. I originally thought it would take me about 6 months or so with my other responsibilities, but that was when I also thought the biggest changes was mainly the ORM. Turns out a lot more than that has changed. Authentication, Authorization and Form Helper, to name a few. I had custom skeleton templates for the bake tools that had to be rewritten. Plus I also had a customization around the Form Helper with Bootstrap integrated, so I could use bake and have my views baked out to what I wanted them to look like… at least a big chunk of it for the most part. Most of all of that had to be completely rewritten from the ground up because of the differences in version 4. I’m at 6 months now. Again, I have other responsibilities so not all of that time has been spent working on this upgrade. At this point I predict I’m looking at another 6 months at least.
I don’t think there’s really a good guide for upgrading. I could be wrong though. I had intentions to write something myself, but it quickly turned into desperation just to get something completed. For me, I think it’s been easier to start fresh with the new version using bake and move code over/modify as needed. There’s very little similarities between version 2 and 4. Same ideas/conventions I guess, but technically, very little similarities in code.
I loved version 2. I know many didn’t and I don’t really know why, but for me it really clicked back then and was a moment of enlightenment if you will. haha I’m older, but this upgrade has really made me feel like we’ve forgotten some of the challenges of coding that we had in a pre framework world. Repetitive difficulties that CakePHP took care of in the background in version 1 and 2. Now those challenges are being replaced with more complex coding practices/features that just add a different challenges/difficulties. Maybe it’s just my old age. Enough of my rambling…