I am (finally) upgrading an old CakePHP 3.* project to something more recent. I have installed PHP 7.4, 8.2 and 8.4 on my system. I managed to get the project to CakePHP 3.10, but the upgrade to 4.0 fails because PHP is either too old or too new:

$ php82 /var/www/composer.phar require --dev --update-with-dependencies "phpunit/phpunit:8.0.*"
./composer.json has been updated
Running composer update phpunit/phpunit --with-dependencies
Loading composer repositories with package information
Updating dependencies                           
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - cakephp/cakephp is locked to version 3.10.5 and an update of this package was not requested.
    - cakephp/cakephp 3.10.5 requires php >=5.6.0,<8.0.0 -> your php version (8.2.29) does not satisfy that requirement.
  Problem 2
    - cakephp/bake is locked to version 1.3.7 and an update of this package was not requested.
    - cakephp/bake 1.3.7 requires cakephp/cakephp >=3.4.0 <4.0.0 -> satisfiable by cakephp/cakephp[3.10.5].
    - cakephp/cakephp 3.10.5 requires php >=5.6.0,<8.0.0 -> your php version (8.2.29) does not satisfy that requirement.


Installation failed, reverting ./composer.json and ./composer.lock to their original content.
$ php74 /var/www/composer.phar require --dev --update-with-dependencies "phpunit/phpunit:8.0.*"
./composer.json has been updated
Running composer update phpunit/phpunit --with-dependencies
Loading composer repositories with package information
Updating dependencies                           
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - cakephp/plugin-installer is locked to version 2.0.1 and an update of this package was not requested.
    - cakephp/plugin-installer 2.0.1 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
  Problem 2
    - cakephp/cakephp is locked to version 3.10.5 and an update of this package was not requested.
    - cakephp/cakephp 3.10.5 requires laminas/laminas-diactoros ^1.4.0 -> satisfiable by laminas/laminas-diactoros[1.8.7p2].
    - laminas/laminas-diactoros 1.8.7p2 requires laminas/laminas-zendframework-bridge ^1.0 -> satisfiable by laminas/laminas-zendframework-bridge[1.8.0].
    - laminas/laminas-zendframework-bridge 1.8.0 requires php ~8.1.0 || ~8.2.0 || ~8.3.0 -> your php version (7.4.33) does not satisfy that requirement.


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

So now I’m stuck between a rock and a hard place. Any suggestions on how to resolve this? I’m a but surprised by the requirement of cakephp/plugin-installer to require PHP >= 8.1, in the composer.json it is set like this:

"cakephp/plugin-installer": "*",

while in a newer project (generated last year with CakePHP 4) that same version is set to ^1.3.

instead of doing it via composer require just try to adjust your composer.json to the new version constraints and do a composer update -W