To upgrade to Craft 4, you'll need to make sure that Composer is allowed to upgrade all of your plugins to their Craft 4 compatible releases as well. This is done by manually editing your installed plugins' version constraints in your composer.json
file.
The reason why this is necessary is that most plugins are bumping their major version for the Craft 4 compatible release – for example, Feed Me is going from version 4.x to 5.x for the Craft 4 compatible release – and in most cases, Composer isn't able to upgrade an installed package to a new major version automatically. This is due to version constraints in the composer.json
file, and in general this is a good thing – major version upgrades often include breaking changes, and those constraints prevent Composer from accidentally upgrading to a version that could break your application.
As an example: in order to allow Composer to update Feed Me to the Craft 4 compatible version, you'll need to change the craftcms/feed-me
package's version constraint from this:
"require": {
...
"craftcms/feed-me": "4.5.1"
...
},
To this:
"require": {
...
"craftcms/feed-me": "^5.0.0"
...
},
You'll need to step through each of your installed plugins to find the version you need to add to your composer.json
file. The easiest way to do that is probably visiting the new "Craft 4 Upgrade" utility, which is found under Utilities -> Craft 4 Upgrade inside the Control Panel. This utility is available in Craft 3.7.39 or later, and lists all the latest, compatible versions for any and all plugins installed.
Note that some plugins may still be in beta for their Craft 4 compatible release. If so, make sure to add the -beta
part to the version constraint for that plugin as well, i.e. so it looks like this:
"require": {
...
"nystudio107/craft-retour": "^4.0.0-beta"
...
},
After making sure that all plugins have a Craft 4-compatible version constraint declared in your composer.json
file, run composer update
.
If that didn't work and you're still getting Composer errors – and some of your plugins' versions are in fact beta releases – try adding the following rules to your composer.json
file:
"minimum-stability": "beta",
"prefer-stable": true,
Then try composer update
again.
Also note the official Craft 4 upgrade guide.