Update Composer.json

Update Composer

Before updating composer.json file, it would be good to get the latest version of composer:

composer self-update --2

Or, if you are using the phar, just get the latest version.

Remove composer.lock

In your project root:

rm composer.lock

Update your composer.json

We recommend using the Composer Update Tool from @dereuromark. You just paste your composer.json content, and it outputs the new one. However, if you are an old school guy, you can always do it manually.

If you used the Composer Update Tool please go to Add some extra tools for code verifying

Update plugins

This task that needs to be done manually. You need to find the specific CakePHP 4 versions for the plugins you are using and set the proper version in the composer.json

i.e

If you are using CakeDC/Users plugin, and you are using CakePHP 3.7 then the plugin version must be 8.5. Since this version explicitely requires CakePHP 3, you need to update the composer.json to request "cakedc/users:^9.0". To do that we execute:

php composer.phar update cakedc/users

Update PHPUnit and CakePHP Dependencies

We can now run:

php composer.phar require --dev --update-with-dependencies  "phpunit/phpunit:~8.5.0 || ^9.3"
php composer.phar require --update-with-dependencies "cakephp/cakephp:^4.0"

Add some extra tools for code verifying

  • Add PHP-CS, PHPStan, PSalm:
    composer require --dev phpstan/phpstan phpstan/extension-installer cakedc/cakephp-phpstan:^2.0 psalm/phar:~3.11.2

Go to the next step (Update Application.php)

NEED A CUSTOM SOLUTION?
GET IN TOUCH:

We Bake with CakePHP