cakephp / upgrade

Upgrade tools for CakePHP meant to facilitate migrating from one version of the framework to another
MIT License
110 stars 60 forks source link

Upgrade from 3.10 to 4.0 with PHP 7.2 #220

Closed grumbma closed 8 months ago

grumbma commented 1 year ago

The composer.json in branch 4.x requires PHP ^8.0, which is higher than what CakePHP 4.0 requires. The page guide on https://book.cakephp.org/4/en/appendices/4-0-upgrade-guide.html says that PHP ^7.2 is needed to upgrade.
Therefore, the Upgrade tool should require the same PHP version CakePHP requires.

grumbma commented 1 year ago

Actually, CakePHP 3.10 requires PHP >=5.6.0,<8.0.0. This makes the upgrade tool incompatible with CakePHP 3.10. Therefore, in the current state, it can't be used to upgrade 3.10 to 4.0.

markstory commented 1 year ago

Therefore, the Upgrade tool should require the same PHP version CakePHP requires.

While that sounds nice in theory, the tools that this upgrade tool is built on (rector) require newer PHP versions. If you're unable to update your system PHP to meet the needs of this tool you could try using docker/podman to run the necessary version of PHP, and then delete the image once you're done.

This makes the upgrade tool incompatible with CakePHP 3.10. Therefore, in the current state, it can't be used to upgrade 3.10 to 4.0.

Is this an offer to help rebuild the upgrade tool to meet your requirements? There is unlikely to be much interest on the core team to retrofit that version of this tool. We're currently working on getting this tool ready for the upgrade from 4.x to 5.0.

grumbma commented 1 year ago

My approach would be first to try to lower the requirements and hope no mayor errors occur and if that does not work checkout at a commit in the past (e.g. #145) and try running that version.
Am I thinking too simple? Is there a better revision to choose?
Creating this Issue, I was thinking that a tag or something at the right version of this tool for upgrading 3.10 to 4.0 would solve this problem.

I'm not asking for a new tool just for my requirements. I'm only asking for a version of the tool I thought existed in the past.

markstory commented 1 year ago

My approach would be first to try to lower the requirements and hope no mayor errors occur and if that does not work checkout at a commit in the past (e.g. https://github.com/cakephp/upgrade/pull/145) and try running that version. Am I thinking too simple? Is there a better revision to choose?

That sounds like it could work. We won't be able to fix any problems you find at that point, but you might be a revision of the tool that runs on PHP7.

berarma commented 12 months ago

I'm a bit confused. The docs say the Upgrade tool can run on PHP 7.2 - 8.2. The composer.json requires at least 8.0 but the lock file installs on PHP 7.2 without issues.

Now I'm trying to run the migration but it throws the error:

PHP Fatal error:  Declaration of Cake\Upgrade\Application::console(Cake\Console\CommandCollection $commands): Cake\Console\CommandCollection must be compatible with Cake\Core\ConsoleApplicationInterface::console($commands) in /home/bernat/p/upgrade/src/Application.php on line 49

Who's right?

Correction: I thought I was using a lock file from the project but instead it was created by me before using PHP8

berarma commented 12 months ago

I made it work. The composer.lock file is outdated so a "composer update" is required but the docs ask to run "composer install".

The docs also say the Upgrade can be done on PHP 7.2 - 8.2 but PHP 8.0 - 8.2 is required instead.

Also, I had to remove the vendor directory of the project I was upgrading or the rector changes would consume all my RAM and would never end.

LordSimal commented 12 months ago

the docs are indeed a bit outdated. A PR to fix this is welcome 👍🏻

berarma commented 12 months ago

the docs are indeed a bit outdated. A PR to fix this is welcome 👍🏻

OK. But I'm not sure how to deal with the vendor directory issue.

LordSimal commented 12 months ago

I have not yet had this problem with "infinite RAM usage" when doing my upgrades with the tool.

umer936 commented 11 months ago

I think a link to the last commit that allows installing on PHP 7.x is worth having. I'm not ready to commit to PHP 8 yet, but I need a CakePHP 2 app upgraded to CakePHP 4 before I will be able to. I checked out https://github.com/cakephp/upgrade/commit/0db6dc2a06b5f97e0ad8f6e56bc7738c9efb3c45 so I can move to the step of 3.x to 4.x.

berarma commented 11 months ago

I think a link to the last commit that allows installing on PHP 7.x is worth having. I'm not ready to commit to PHP 8 yet, but I need a CakePHP 2 app upgraded to CakePHP 4 before I will be able to. I checked out https://github.com/cakephp/upgrade/commit/0db6dc2a06b5f97e0ad8f6e56bc7738c9efb3c45 so I can move to the step of 3.x to 4.x.

You can run the upgrade using PHP 8 on a virtual machine then keep using PHP 7 after that.