A client of mine has a rather complex website (so lots of backend stuff) built with CakePHP 1.2.5. They want to migrate it to the latest version. I myself haven’t worked with CakePHP in a very long time, so I’m wondering how complicated it would be to migrate it vs rebuilding it at this point. I’ve found guidelines that take me step by step up by a version, but it seems pretty tedious and I’m wondering if this might end up just making a huge mess in the code.
Having twice been through migrating applications from 1.3 to 3.x, I can tell you a bit about what I did and what problems there were.
The process that I used was to run the various automated tools to do what they could. These basically just rename files and classes, add namespace and use declarations, that sort of thing. I then separately baked the entire database to get a “modern” version, because things like validation have changed quite substantially.
This gives me two separate versions, which I ran WinDiff on. I was able to find a few quite common things that I had done in the original version and wanted to preserve, so I tweaked the bake templates. There were also some easy-to-code conversions from the old version which I added to the migration process. And then re-ran the entire process again to refresh the two separate versions.
I then used WinDiff to go through all the remaining differences, copying old customizations (algorithms, validation, etc.) from the old to the new, and updated them as required (e.g. changing data from array access to entity objects). There were some fairly straight-forward global search and replaces that I was able to do on the old version to replace most of array accesses and simplify this process.
When I was ready to start testing, I added “TODO” to the beginning of every single function, and removed them as I went along, so that I could easily track which functionality I had tested and which I hadn’t.
When I did all of this, the middleware versions of things were not yet in place, authentication and authorization plugins didn’t exist, etc., so I’ve since had to go back and do additional processes to incorporate those. You’ll be in a better position as you’ll get straight to them.
The biggest pain that I had was probably migrating the validation and rules. That’s an area where most applications are likely going to have a lot of custom work, the structure has changed completely, and not in a way that any automated tool will be likely to help with.
The other thing to be careful of, if you do search and replace for array accesses, is that capitalization and pluralization have changed, and the top-level data is in a different place. For example, if you have Articles which have Authors, and read a single Article Cake 1.2 might have $article['Article']['title']
and $article['Author']['name']
, for example, but 3.x will have $article->title
and $article->author->name
. But if you read an author, it’ll be $author->name
instead of $author['Author']['name']
. So you can’t just blindly replace ['Author']['name']
with ->author->name
, because sometimes it’s just ->name
that you want. Hope that makes sense.
My experience is more limited and different.
I wrote a site in 1.x when I wasn’t even clear on what Objects were. It’s where I learned… sort of.
Later I wrote a pretty large app in 2.x that has been running for a good long time. By this time I had a few OOP concepts to work with but was clawing my way to almost every solution. The result was a functioning rats-nest of coupled classes and weirdness.
Server security concerns have made it prudent to look at modernizing. So, into cake4.x with much more experience.
The old app is really not worth migrating because it got so much wrong at the structural level. And we learned that many ‘necessary’ features were never used at all.
So, a nice modernized rewrite is in order from the db schema up.
SOLUTION- My experience is more limited and different.https://nox.tips/
I wrote a site in 1.x when I wasn’t even clear on what Objects were. It’s where I learned… sort of. https://mobdro.onl/
Later I wrote a pretty large app in 2.x that has been running for a good long time. By this time I had a few OOP concepts to work with but was clawing my way to almost every solution. The result was a functioning rats-nest of coupled classes and weirdness.
Server security concerns have made it prudent to look at modernizing. So, into cake4.x with much more experience.
The old app is really not worth migrating because it got so much wrong at the structural level. And we learned that many ‘necessary’ features were never used at all.
So, a nice modernized rewrite is in order from the db schema up.