CakePHP Upgrade tool
Upgrade tool as standalone application for CakePHP meant to facilitate migrating
- from CakePHP 2.x to 3.x.
- supports the minor upgrades in 3.x - up until currently 3.8+.
- supports basic stuff for 4.x
Warning This tool is still under development and doesn't handle all aspects of migrating.
CakePHP 4
Tasks available now for CakePHP4 (and super helpful):
- method_names
- method_signatures
- skeleton
Fore more please look into wiki for hot new tips, also add yours!
CakePHP 3 Please look into this article for Upgrading applications for 3.6+. The new tool rector seems to be very promising.
CakePHP 2 When migrating from 1.x to 2.x you might want to look in the old cakephp-upgrade plugin instead.
Installation
This plugin is standalone. Do not try to mix this with your existing app. Instead, put it somewhere completely separate from it. Best to clone it (git clone ....).
After downloading/cloning the upgrade tool, you need to install dependencies with composer
composer install
Once dependencies are installed you can start using the upgrade
shell.
Note: If you want to get the latest master, you can run composer update
at your own risk.
It will download also all recent changes done.
Alternatively, you can lock it down to a stable version and then update.
IMPORTANT NOTICE
This tool is a split-off off the original CakePHP upgrade tool and provides additional fixers:
- Templates
- Url
- Locale (fixing locale files)
- Model to Table (making the model files to Table class files)
- Fixture loading and casing
- Custom (tons of custom fixes)
Feel free to manually port those things back into the core one.
Usage
Upgrade command
bin/cake upgrade /home/mark/Sites/my-app
Upgrade legacy shell
The upgrade tool provides a standalone application that can be used to upgrade other applications or cakephp plugins. Each of the subcommands accepts a path that points to the application you want to upgrade.
bin/cake upgrade_legacy all /home/mark/Sites/my-app
bin/cake upgrade_legacy skeleton /home/mark/Sites/my-app
The first command would run all the tasks at once on /home/mark/Sites/my-app
,
which is probably the way most people will want to use it.
Additionally the second command would run the skeleton
task on /home/mark/Sites/my-app
.
This command is not included in all
as it is only necessary for apps. Plugins don't need it.
For plugins, point it to the root and use the -p
plugin syntax:
// Upgrading 2.x /home/mark/Sites/my-app/Plugin/MyPlugin/
bin/cake upgrade_legacy all -p MyPlugin /home/mark/Sites/my-app
It is recommended that you keep your application in version control, and keep backups of before using the upgrade tool.
Order matters
Several of the commands have dependencies on each other and should be run in a specific order. It is recommended that you run the following commands first before using other commands:
bin/cake upgrade_legacy locations [path]
bin/cake upgrade_legacy namespaces [path]
bin/cake upgrade_legacy app_uses [path]
Once these three commands have been run, you can use the other commands in any order.
The all
command already used the right order by default.
Tasks Available
For detailed task descriptions and usage see docs.
Also note the wiki with more recent tips.
Using Tagged Releases
For simplicity the tool uses the latest dev-master branches of framework and app repos (or you can get there using composer update
).
If you want to use the stable releases instead, just switch those in the composer.json and then run composer update
again.