Migration from 4.0.7 to?

Hello everyone.

My project is currently using:
CakePHP 4.0.7
XAMPP 3.2.4
MSSQL Server 16
PHP 7.4

But we need to migrate to a new server, this server is set with a more updated environment.
XAMPP 3.3.0
MSSQL Server 22
PHP 8.2

I am getting the following error:
“Type of Cake\View\Exception\MissingTemplateException::$file must be string”

I saw that this error has been solved with the version CakePHP 4.3.
Please could you help me with this migration?

How could I migrate my code to a new version without needing to make big changes to my code?
I found this page, but frankly speaking, it is a little bit confusing to me.

Will I need to run the below command 2 times?
php composer.phar require --update-with-dependencies "cakephp/cakephp:^4.2"
php composer.phar require --update-with-dependencies "cakephp/cakephp:^4.3"

And then, the below line?
bin/cake upgrade rector --rules cakephp43 C:\xampp\htdocs\ormsystem\src
Or this?
bin/cake upgrade rector --rules cakephp43 C:\xampp\htdocs\ormsystem\vendor\cakephp\cakephp\src

If I want to update to the newest version, will I need to make big changes to my code? What could be the highest version that I could use without needing to make big changes to my code? If I want to migrate to version 4.6, does that mean I need to run it version by version? (4.2, 4.3, 4.4…) Should I include version 4.1?

And then, will I need to apply more changes?

As we have talked directly in slack the recommended way of doing this is going from minor to minor (4.0 => 4.1 => 4.2 => 4.3 => 4.4 => 4.5 => 4.6, then 5.0 and so on)

Each minor version has its own upgrade ruleset, so your first upgrade to 4.1 would be

php composer.phar require --update-with-dependencies "cakephp/cakephp:^4.1"

and if it doesn’t error

bin/cake upgrade rector --rules cakephp41 C:\xampp\htdocs\ormsystem\vendor\cakephp\cakephp\src

if the composer command errors you will have to look at the error and see, which other package is not cakephp 4.1 compatible.

If I want to update to the newest version, will I need to make big changes to my code?

This can’t be answered in general since it highly depends on which cakephp features you are using.

As you see this is NOT something you can do via just a few mouse clicks or even in 15 minutes.

1 Like