Upgrading from 2 to 3

A lot of this is subjective, and I apologise for that, but here goes.

I’m quite possibly the oldest poster here, 73 in 2 months (hands up anyone older!). I started fixing hardware and writing software in 1967. About six years ago I wrote a web site for our local Probus Club using CakePHP 1.3 , and I’ve modified/enhanced it since, and we’re now on 2.10. I’ve had a couple of stabs at upgrading to 3, but decided this winter (summer is for golf) to try seriously to get to 3.6. Having been in software for > 50 years I understand the importance of keeping up to date.

My experience however so far has not been good. I’ve got to where I can display the first couple of pages, but the experience seems to indicate I have to change a few hundred “find” statements, each requiring more lines of code than previously, and so-far-uncounted Session code, and I don’t know what else is in store.

What really concerns me however is that what I have done so far runs much (like 4 or 5x) slower (judged by how long it takes the page to load) than the equivalent code on 2.10. This is running in exactly the same (test) environment .

So, I appreciate that the new ORM has major improvements, but I don’t think I need them, and at the current rate of progress I might not live long enough to get to 3.6 (or at least will lose interest in coding), and I see 4 on the horizon.

My questions are:-

Is anyone able to convince me I should put in the effort to get to 3.6 and beyond?

What happens if I stay with 2.x?

Thanks

pete

but the experience seems to indicate I have to change a few hundred “find” statements, each requiring more lines of code than previously

That’s seems to be an indication of writing too much querying code in your controller and not using custom finders feature which exists in 2.x too. That said 3.x’s ORM still supports passing find() options as array similar to 2.x so you can use that to make your job easier.

What really concerns me however is that what I have done so far runs much (like 4 or 5x) slower (judged by how long it takes the page to load) than the equivalent code on 2.10. This is running in exactly the same (test) environment .

3.x code should surely not be slower by that order of magnitude. Only way to know the reason for the slowdown would be to profile the code. Also I hope you are comparing with debug mode turned off. Also might be a good time to update your environment too for e.g. using PHP 7.x.

Is anyone able to convince me I should put in the effort to get to 3.6 and beyond?

Can’t really comment on that. At the end of the day it’s up to you.

What happens if I stay with 2.x?

Won’t be the end of the world but you will be stuck will be a defunct version of framework. Once 4.0 is released in few months 2.x will only get security updates no bug fixes (or enhancements).

I’ve been upgrading several sites from 2.x to 3.4 (can’t go any upper due to php extensions not available).
It was a long way but really easy.
I first used the same (when possible) syntax (find() etc.) and array like mode so it was easy to update and compare.
Then as my understanding of 3.x grew up, I turned to object type everywhere.
3.x is MUCH quicker than 2.x
As you have a long practice of coding, you should not get into real trouble and you’ll soon be very happy with the new style.
Believe me :slight_smile:

Thanks ADmad and 6120 for you comments. I agree PHP 7.x is a good place to be. I have run the existing 2.10 application on 7.2. It is mostly good but having issues with tcpdf, but can continue testing with errors turned off in the tcpdf code.

I’m encouraged 6120’s experience, thanks, will continue with efforts to get to 3.6

I have 2 weeks vacation right now, will attack this again on my return. :sunglasses:

I feel like a bit of an old-timer myself as I’ve been with the framework since 2005 (v1.1). Like you, I remained on the 2.x branch for a very long time, and still have some projects there.

However, the last year or so I’ve dedicated myself to learning 3.x along with many other “updates” in the PHP world (composer and others).

I can say that it’s well worth your time and effort to keep learning 3.x. The ORM is the obvious major change although I would say that, overall, you’re better off if you maintain the approach that you’re learning a brand new framework.

I think the rich-object nature of the 3.x world requires a different thought paradigm. You’ll simply approach your questions differently once you start to see how the ORM layer works. For this reason, I would also suggest rewriting your current app rather than attempting to migrate it.

You’ll probably find that your architectural and design strategies will change, and not just the tactical implementation.

EDIT: My experience of 3.x has also been that, paired with PHP 7.x, it’s super fast. So you may be running into other issues if your experience is that it’s even slower than 2.

I’m only a casual (but longtime user), but I would add this… A few months ago I upgraded an app from 3.3.16 to 3.5.10. I had been dreading the upgrade, assuming it would break things. But as it turned out, all I had to do was update the composer file and run the upgrade. No other changes to my app were required.

So kudos to the CakePHP team for making the 3.x branch far easier to maintain than even 1.x or 2.x.

That said, it did take me a while to move from 2.x to 3.x, as it required some mental readjustments in how I thought about the ORM layer and code. Like anything, it took practice.

I also agree with the advice above, if your app doesn’t have hundreds of pages and controllers, it might be easier to just start from scratch building the Models and Controllers with the new syntax. Even better, try baking them to start, to better understand how it all works together. That one of the best things about CakePHP. Views are more easily portable.