Pixel and Tonic will be releasing Craft CMS 4 on May 4th of 2022. For those looking to get a feel for the upgrade, Craft CMS 4 is now in a stable format and we highly recommend upgrading if you're currently on Craft 3. Some plugins like SproutSEO are still not compatible with Craft 4m, but otherwise, your upgrade should go over relatively smooth if you're able to manage the backend upgrades with PHP, MySQL, and Composer 2. In this article, we will review Craft CMS 4’s exciting new features, how to upgrade to Craft CMS 4.
Craft CMS 4 Performance
Craft CMS 4 aims to significantly improve the authoring experience, from faster performance to new conditional fields, there’s a lot to be excited about. Among one the biggest frustrations with Craft 3 is the performance when getting into more complex data models. Particularly content that relies heavily on nested Matrix, neo, and super table blocks. Now in Craft CMS 4, making drafts and edits has been noted to be considerably faster.
Craft CMS 4 Content Authoring
One of the features we’re most excited about is conditional fields. Fields can now be set to show/hidden status based on certain conditions. This will allow developers to create more robust components without the headaches of having too many confusing options. Relation conditions bring new functionality for limiting which elements (entries, users, and assets) are related. Site admins can also configure which element index sources are available, based on certain conditions. Additionally, Craft CMS 4 brings new element index filtering, allowing authors to filter elements based on conditional rules, such as entry type and author. Lastly, categories will now be savable as drafts, in addition to entries.
Craft CMS 4 Asset management
Craft CMS 4 is stepping up its game with asset management. Asset volumes are now dissociated with types and managing operations. Instead, volumes are assigned to a “filesystem” to manage files. Filesystems can also vary per environment. Additionally, you can have a separate filesystem dedicated to just image transforms, while also having a non-public facing system for assets. Assets can also be isolated to just a single directory, including subfolders.
Making your own custom alt-text fields for image assets is now a thing of the past. Craft CMS 4 is finally adding the alternative text natively to image assets.
Upgrading to Craft CMS 4
Will upgrading to Craft 4 be simple? Yes and no. For some sites, it may come down to a few clicks, updating the server, and changing some lines of code. For larger and more complex websites, an upgrade will be more extensive. If you’re attempting to upgrade to Craft 4, we always recommend making a database backup first. It’s also not a bad idea to backup your entire server should things go south. Next, the server will need to be upgraded to PHP 8.0.2+ and MySQL 5.7.8+. Your website will also need to be on the latest version of Craft 3.7. Deprecated errors should also be addressed before upgrading to Craft 4. If you’ve kept up to date with that, the rest should be relatively easy.
Execute within a terminal: php craft project-config/rebuild
Next, update your composer.json to require
"craftcms/cms": "4.0.0-beta.1" plus any plugins that are compatible with Craft 4.
Run in terminal
php craft migrate/all.
Once you’ve completed the upgrade, you’ll want to address any deprecated errors or failing dependencies. This is where the majority of time may need to be spent for more complex Craft builds. Lastly, test your pages, forms, and plugins to make sure everything works properly.
List of Craft 4 features
According to Craft 4’s roadmap, there are several new features already in the works for 4.0 and future releases. Below are the ones we’re most excited about.
WCAG 2.1 AA Compliance [4.1]
Custom element sources [4.0] #8423
Flysystem 3 [4.0] #7687
Integrate money library [4.0]
Symfony Mailer [4.0] #10062
Bulk element editing [4.x] #8132
Default status element index setting [4.x] #8926
Integrate Carbon library [4.x]
Nested Matrix Fields [4.x] #8101