cakephpcomposer-phpupgradecakephp-4.xcakephp-3.8

How do I resolve Composer dependency upgrading to CakePHP4?


I'm following the upgrade instructions for moving a CakePHP project to version 4. All went well until the final command:

php composer.phar require --update-with-dependencies "cakephp/cakephp:4.0.*"

This resulted in

Problem 1

  • cakephp/bake 1.11.2 requires cakephp/cakephp ^3.8.0 -> satisfiable by cakephp/cakephp[3.8.0, >>3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.2, 3.8.3, 3.8.4, >>3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.x-dev] but these conflict with your requirements or >.minimum-stability.
  • cakephp/bake 1.11.2 requires cakephp/cakephp ^3.8.0 -> satisfiable by cakephp/cakephp[3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.x-dev] but these conflict with your requirements or minimum-stability.
  • cakephp/bake 1.11.2 requires cakephp/cakephp ^3.8.0 -> satisfiable by cakephp/cakephp[3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.x-dev] but these conflict with your requirements or minimum-stability.
  • Installation request for cakephp/bake (locked at 1.11.2, required as ^1.9.0) -> satisfiable by cakephp/bake[1.11.2].

The VERSION.txt for the project shows CakePHP at 3.8.11.

In the composer.json file:

    "require-dev": {
          "cakephp/bake": "^1.9.0",
           "cakephp/cakephp-codesniffer": "^3.0",
           "cakephp/debug_kit": "^3.17.0",
           "josegonzalez/dotenv": "3.*",
           "psy/psysh": "@stable"
       },

Solution

  • Without updating, 1) change all requirements according to the latest 4.x application template's composer.json file, 2) change the requirements for other CakePHP plugins that you might have installed to a 4.x compatible version too, and then 3) update your dependencies.

    composer require --no-update "cakephp/cakephp:^4.0" "cakephp/migrations:^3.0@beta"
    composer require --no-update --dev "cakephp/bake:^2.0.3" "cakephp/cakephp-codesniffer:~4.1.0" "cakephp/debug_kit:^4.0" "phpunit/phpunit:^8.5"
    composer update --with-dependencies