A CakePHP plugin helping in the upgrade process from 1.x or 2.x to the latest stable release
Helps automating the upgrade process from CakePHP 1.1/1.2/1.3 to CakePHP 2.x and above.
This plugin is now in "feature-freeze" in favor of the all new standalone CakePHP Upgrade Tool - built with CakePHP 3.x. Please help to migrate all 2.x and 3.x relevant upgrade commands to this new repo.
The original one lacks a lot of things that could be done automatically. Changes have been reported as ticket, but so far it has not yet made it into the official version.
Note: Some of the following "installation" steps are only necessary upgrading from 1.x (like folder renaming). Do not think of them as a perfectly adjusted worklist (also don't mind the order). Every app, every setup is different. It is more a small guide to get the basics straight.
It can also apply a lot of additional sugar and enforce coding standards etc. Those commands are not vital, but nice to have.
Execute the following from within the folder where your composer.json file is located:
composer require --dev dereuromark/cakephp-upgrade dev-master
a) Make sure you got the lastest stable 2.x version of the CakePHP core. Usually you just copy the
/lib folder of the current Cake master branch into a
/lib folder next to your
b) Copy this plugin into your
/app/Plugin folder as
c) Manually rename
/app/config folder to
/app/Config (we need the bootstrap.php here).
CakePlugin::loadAll(); in your app/Config bootstrap to make sure this plugin is loaded.
e) Either put the cake shell from the downloaded 2.x repository in app/Console or use the lib/Cake one.
f) Ready to go! Run any of the available commands (see details below). The most important one is
locations and should be run first.
Don't forget to remove the old (1.x)
/cake folder and manually clear the (persistent) cache before running the shell.
I never really had to manually replace my core.php with the new 2.x core.php. But as there are many new features introduced, it might make sense to do that. Just don't forget to merge your existing settings like salt and cache/session/cookie settings. Or at least compare your config files to the current master ones.
Remember: At this point you are already using the shell as 2.x shell. "cake1.x" or whatever you used before is now officially dead.
Also: Mind the casing! Uppercase/lowercase is important.
As this is a plugin, use it with:
cake Upgrade.Upgrade [command]
Running it without any command will get you a list of possible commands to chose from. Make sure to check on this first. You might have to set the executable rights for your cake shell first in order to run any shell (on unix anyway).
Note: If you use Unix the full command (relative from your app dir!) would be:
../lib/Cake/Console/cake Upgrade.Upgrade [command]
..\lib\Cake\Console\cake Upgrade.Upgrade [command]
And if you use the app/Console shell instead (for this to work, you also need to copy over the Console files from /Templates/skel/ in the core repo):
Console/cake Upgrade.Upgrade [command]
.\Console\cake Upgrade.Upgrade [command]
The short version using APP/Console is preferred as you will need those files anyway at some point. It is also the documented approach to call shells in 2.x. Especially if you plan on using composer for your 2.x app.
- webroot (important)
- database (important)
- routes (important)
- paginator (run only once!)
and many more
- svn (linux/windows)
- group commands
- except command (all except for a few, e.g.
except paginatorto skip paginator method)
Additionally you can use the CorrectShell to correct
cake Upgrade.Correct [command]
Tip: You can use
cake Upgrade.Correct all to quickly apply all relevant correction commands.
Tip2: The probably most important feature for me is that my version cleanly separates app and plugins. Without -p PluginName it leaves them alone. If you want to upgrade plugins use
cake Upgrade.Upgrade [command] -p PluginName
I also added support for -p * - to address all plugins at once.
This is only fully supported by the
group command like so:
cake Upgrade.Upgrade group [command1] [command2] ... -p *
You need to supply at least two commands (if you want to use only one, type it twice:
cake Upgrade.Upgrade group [command1] [command1] -p *
This is necessary because 1 argument stands for a config group
The not fully tested way of using the plugin wildcard would be
cake Upgrade.Upgrade [command] -p *
which should just grab all files at once and process them
The convert shell currenently handles:
- Array syntax from long array() to short  (PHP5.3 to PHP5.4)
This is mainly Tools plugin and app specific stuff. You can disregard this shell.
- Auth::allow(), Layout Stuff and more
- request->query() and Set/Hash replacement
Now creates missing App classes that are required since 2.1
- AppHelper, AppModel and AppController (AppShell is not yet required)
- onlyAllow() to allowMethod() etc
- Some validation rules changed
Use this script ONLY after backing up your app folder.
Also: This powerful plugin is not for N00bs. Do NOT use it if you don't know at least some Cake basics.
- Make sure you have
debugmode enabled and/or cleared the cache.
- Use a fresh 2.x app and play with the plugin to get a grasp on how the new major version works, and how the plugin operates, if it is your first trial with 2.x. Then - with some more insight - it will be easier to migrate 1.x apps to 2.x.
Either use git or svn or some other version control to verify the changes made.
This way you are able to detect wrong replacements right away. So better use every upgrade command separatly and commit/push after each successful run.
If sth goes wrong with one command you can easily revert to the last step this way. The
regexp commands sometimes can be too eager and have not been tested to their full extend. So please be careful.
So the ideal order might be:
- [the rest - the application might already be browsable again at this point]
- make sure you add missing App::uses() statements to your class files
- fix some more ESTRICT errors
- apply missing configuration for new features
AND everything else that is not yet covered but meticulously documented in the migration guides: