Documentation

Upgrading to Craft 4

Servd automatically supports Craft 3 and Craft 4 projects out-of-the-box, so upgrading is nice and straightforward. Here are a few recommended steps to guide you through the process:

Upgrade Steps #

  1. Follow Craft's upgrade guide to get everything upgraded and working on your local machine.

  2. Commit and push all code and project config changes made as part of the upgrade to your git repository.

  3. If you've had to increase your local PHP version during the upgrade, tweak the PHP version of your project in Servd. Note: this won't change the PHP version of your existing bundles, or immediately update the PHP version running in any of your environments. It just changes the version that's used for new bundles.

  4. Create a bundle from your commit.

  5. Check your post-deploy tasks contain the "./craft migrate/all --interactive=0" and "./craft project-config/sync --interactive=0" craft commands.

    If they don't, either add them, or manually run the commands via SSH or the dashboard once the bundle is synced.

  6. Once built, select and sync the new bundle to your staging or development environment.

  7. Give your staging/development environment a thorough test to make sure it's working as you expect.

  8. Select and sync the bundle to your production environment.

  9. Give your production environment a test.

  10. You're now running on Craft 4! 🎉

For Larger And More Complex Upgrades #

Sometimes for larger projects, and for upgrades that require data to "massaged" a little, it can be a good idea to use Servd's environment clone tools to prepare an upgraded version of the site on staging, then clone the site up to production. Here are a few steps for doing this:

  1. Go to your staging's Import page and clone production's assets, currently deployed bundle and database.

  2. Once complete, create a bundle containing all your Craft 4 changes.

  3. Deploy the upgraded bundle to staging.

  4. Once it is deployed and post-deploy tasks have completed, perform any manual modifications to the data in the staging database as required.

  5. Go to your production Import page and trigger an import into production from staging that includes the database and deployed bundle. If any assets have changes or new environment variables have been introduced, you may want to enable those options as well.

    It's a good idea to enable Atomic Database Imports for this step, as we've found Craft 3 sometimes tries to populate plugin data into the database if it discovers that the table is empty. This can result in the correct Craft 4 plugin info not being populated correctly during the upgrade process.

Note: this solution isn't as suited for projects that are regularly storing user data and orders (e.g. e-commerce sites) as it will lose data that is created on production in the interim. In these scenarios, you may consider turning on Craft's maintenance mode during the upgrade to prevent users from submitting data.

Database Upgrades #

The databases running on Servd are compatible with Craft 3 and Craft 4, so fortunately there isn't any action required to upgrade the database as part of the process. 🙌