Skip to content
This is the documentation for pieceofcake2/cakephp, a community-maintained fork of CakePHP 2.x for PHP 8. About this fork.

Upgrade shell ​

The upgrade shell does most of the mechanical work of upgrading an application from CakePHP 1.3 to 2.0: it moves files to their 2.0 locations and rewrites removed APIs, helper calls, constants and so on. It is provided by the pieceofcake2/upgrade plugin.

Piece of Cake 2 fork

UpgradeShell was removed from the core and moved to the pieceofcake2/upgrade plugin. Most applications never need it.

The shell works on applications in the legacy app/ layout, so the examples below run it through vendor/bin/cake. Install the plugin as a development dependency and load it in app/Config/bootstrap.php:

bash
composer require --dev pieceofcake2/upgrade

Composer installs it into plugins/Upgrade/ when your composer.json has the installer-paths setting described in Installing a plugin with Composer.

php
// app/Config/bootstrap.php
CakePlugin::load('Upgrade');

Make a backup of your application (or commit it to version control) before you start. To run all upgrade steps:

bash
vendor/bin/cake upgrade all

If you would like to see what the shell will do without modifying files perform a dry run first with --dry-run:

bash
vendor/bin/cake upgrade all --dry-run

To upgrade your plugin run the command:

bash
vendor/bin/cake upgrade all --plugin YourPluginName

You are able to run each upgrade step individually (tests, locations, i18n, helpers, basics, request, configure, constants, controller_redirects, components and exceptions). To see all the steps and options available run the command:

bash
vendor/bin/cake upgrade --help

The upgrade shell only covers the 1.3 to 2.0 changes. An application converted this way must then be brought up to CakePHP 2.10.24 before it can run on the Piece of Cake 2 fork; see Migrating from CakePHP 2.10 and the migration guides in the appendices.

Rector rules ​

The rector command runs a set of Rector rules for a change of pieceofcake2/cakephp that your code must follow. It is not part of all. Install and load the plugin as above (in config/bootstrap.php in the CakePHP 5 layout), then give the directories or files to change:

bash
# See the changes
bin/cake upgrade rector --rules variadic-arguments src tests --dry-run

# Apply them
bin/cake upgrade rector --rules variadic-arguments src tests
RulesChange
variadic-argumentsAdds the variadic parameter of CakePHP to the methods that override a method that has one, e.g. query($sql) of an AppModel becomes query($sql, ...$params). See Variadic arguments.

The changed code also runs on the versions of pieceofcake2/cakephp before the change, so you can run the rules before you update. See the documentation of the plugin for the details.

Based on the CakePHP Cookbook. Content licensed under CC BY-NC-SA 4.0. Not affiliated with the Cake Software Foundation.