Bin/cake upgrade not working

We have php 8.0.30 installed.

went into the /project/cakephp directory

# Install the upgrade tool
git clone https://github.com/cakephp/upgrade
cd upgrade
git checkout 4.x
composer install --no-dev

run bin/cake upgrade rector --rules cakephp45 src/

Get the following error: Unknown command cake upgrade. Run cake --help to get the list of commands.

Am I missing something to run upgrade?

Thank you.

I can’t reproduce that.

kevinpfeifer➜~/Desktop/tmp» git clone https://github.com/cakephp/upgrade                                                           [22:42:32]
Cloning into 'upgrade'...
remote: Enumerating objects: 3373, done.
remote: Counting objects: 100% (1359/1359), done.
remote: Compressing objects: 100% (427/427), done.
cremote: Total 3373 (delta 888), reused 1238 (delta 840), pack-reused 2014
Receiving objects: 100% (3373/3373), 535.68 KiB | 1.50 MiB/s, done.
Resolving deltas: 100% (1734/1734), done.

kevinpfeifer➜~/Desktop/tmp» cd upgrade                                                                                          [22:42:36]

kevinpfeifer➜Desktop/tmp/upgrade(5.x)» git checkout 4.x                                                                            [22:42:37]
branch '4.x' set up to track 'origin/4.x'.
Switched to a new branch '4.x'

kevinpfeifer➜Desktop/tmp/upgrade(4.x)» composer install --no-dev                                                                   [22:42:42]
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Lock file operations: 56 installs, 0 updates, 0 removals
  - Locking cakephp/cakephp (4.5.5)
  - Locking cakephp/cakephp-codesniffer (4.7.0)
  - Locking cakephp/chronos (2.4.4)
  - Locking composer/ca-bundle (1.5.0)
  - Locking dealerdirect/phpcodesniffer-composer-installer (v1.0.0)
  - Locking doctrine/instantiator (2.0.0)
  - Locking laminas/laminas-diactoros (2.26.0)
  - Locking laminas/laminas-httphandlerrunner (2.10.0)
  - Locking league/container (4.2.2)
  - Locking mikey179/vfsstream (v1.6.11)
  - Locking myclabs/deep-copy (1.11.1)
  - Locking nette/utils (v3.2.10)
  - Locking nikic/php-parser (v5.0.2)
  - Locking phar-io/manifest (2.0.4)
  - Locking phar-io/version (3.2.1)
  - Locking phpstan/phpdoc-parser (1.29.0)
  - Locking phpstan/phpstan (1.10.27)
  - Locking phpunit/php-code-coverage (9.2.31)
  - Locking phpunit/php-file-iterator (3.0.6)
  - Locking phpunit/php-invoker (3.1.1)
  - Locking phpunit/php-text-template (2.0.4)
  - Locking phpunit/php-timer (5.0.3)
  - Locking phpunit/phpunit (9.6.19)
  - Locking psr/container (2.0.2)
  - Locking psr/http-client (1.0.3)
  - Locking psr/http-factory (1.1.0)
  - Locking psr/http-message (1.1)
  - Locking psr/http-server-handler (1.0.2)
  - Locking psr/http-server-middleware (1.0.2)
  - Locking psr/log (2.0.0)
  - Locking psr/simple-cache (2.0.0)
  - Locking rector/rector (0.16.0)
  - Locking sebastian/cli-parser (1.0.2)
  - Locking sebastian/code-unit (1.0.8)
  - Locking sebastian/code-unit-reverse-lookup (2.0.3)
  - Locking sebastian/comparator (4.0.8)
  - Locking sebastian/complexity (2.0.3)
  - Locking sebastian/diff (4.0.6)
  - Locking sebastian/environment (5.1.5)
  - Locking sebastian/exporter (4.0.6)
  - Locking sebastian/global-state (5.0.7)
  - Locking sebastian/lines-of-code (1.0.4)
  - Locking sebastian/object-enumerator (4.0.4)
  - Locking sebastian/object-reflector (2.0.4)
  - Locking sebastian/recursion-context (4.0.5)
  - Locking sebastian/resource-operations (3.0.4)
  - Locking sebastian/type (3.2.1)
  - Locking sebastian/version (3.0.2)
  - Locking slevomat/coding-standard (8.15.0)
  - Locking squizlabs/php_codesniffer (3.9.2)
  - Locking symfony/polyfill-ctype (v1.29.0)
  - Locking symfony/polyfill-intl-grapheme (v1.29.0)
  - Locking symfony/polyfill-intl-normalizer (v1.29.0)
  - Locking symfony/polyfill-mbstring (v1.29.0)
  - Locking symfony/string (v6.4.7)
  - Locking theseer/tokenizer (1.2.3)
Writing lock file
Installing dependencies from lock file
Package operations: 22 installs, 0 updates, 0 removals
  - Installing psr/simple-cache (2.0.0): Extracting archive
  - Installing psr/log (2.0.0): Extracting archive
  - Installing psr/http-message (1.1): Extracting archive
  - Installing psr/http-server-handler (1.0.2): Extracting archive
  - Installing psr/http-server-middleware (1.0.2): Extracting archive
  - Installing psr/http-client (1.0.3): Extracting archive
  - Installing psr/container (2.0.2): Extracting archive
  - Installing league/container (4.2.2): Extracting archive
  - Installing psr/http-factory (1.1.0): Extracting archive
  - Installing laminas/laminas-diactoros (2.26.0): Extracting archive
  - Installing laminas/laminas-httphandlerrunner (2.10.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.29.0): Extracting archive
  - Installing composer/ca-bundle (1.5.0): Extracting archive
  - Installing cakephp/chronos (2.4.4): Extracting archive
  - Installing cakephp/cakephp (4.5.5): Extracting archive
  - Installing nette/utils (v3.2.10): Extracting archive
  - Installing phpstan/phpstan (1.10.27): Extracting archive
  - Installing rector/rector (0.16.0): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.29.0): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.29.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.29.0): Extracting archive
  - Installing symfony/string (v6.4.7): Extracting archive
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
11 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

kevinpfeifer➜Desktop/tmp/upgrade(4.x)» bin/cake                                                                                    [22:42:47]
No command provided. Choose one of the available commands.

Current Paths:

* app:  src/
* root: /Users/kevinpfeifer/Desktop/tmp/upgrade/
* core: /Users/kevinpfeifer/Desktop/tmp/upgrade/vendor/cakephp/cakephp/

Available Commands:

App:
 - help
 - upgrade
 - upgrade file_rename
 - upgrade rector

CakePHP:
 - version

To run a command, type `cake command_name [args|options]`
To get help on a specific command, type `cake command_name --help`

Doing a minor version jump isn’t that hard to do manually to be honest.

You will probably save some time just fixing those errors and deprecations manually instead of relying on the automated rector rules present in the upgrade tool.

Also see https://www.youtube.com/live/GaCqzBuX5sc?si=GCs4VnaTHPmRI0O5&t=11278 for how it should look like when going from Cake 4.5 to 5.0 (should look the same for you when going from 4.4 to 4.5)

Ah, I didn’t realize I had to go into the upgrade folder to run the command. /headdesk that fixed the issue of the command not working.

The Upgrade Tool is its own little CakePHP Application and completely independent of your CakePHP Application.

1 Like