Most of your Craft 5 code keeps working on Craft 6. The trouble is the part that stops working without saying so.
Craft 6 is Craft rebuilt on Laravel, and Pixel & Tonic did a lot to make the move gentle. The Yii2 adapter lets Craft 5 plugins and modules run on Craft 6, and the craft6-revamp tool moves your project into the new folder layout for you. (If you want the bigger picture first, start with what changes in Craft 6.)
I've just been through it: a demo site upgraded from Craft 5 to the 6.0 beta, and my three plugins ported to it. Most things either worked or failed loudly, with an error that told me what to fix. Those are easy. This article is about the other kind: code that runs without complaint and quietly does something different.
Why is a silent break worse than an error?
Because nothing points at it. The page loads, the control panel opens, your tests pass, and you move on. Weeks later someone notices that a label is wrong, a check never ran, or a button never shows up. By then you're looking for the cause in a much bigger haystack.
Everything below was found the hard way. For each one: what you see, why it happens, and what to change.
1. instanceof checks quietly return false
What you see: a feature that depends on the field type just stops, with no error. A Matrix field is no longer treated as a Matrix field.
Why: the adapter keeps the old class names, like craft\fields\Matrix, so your code still loads. But they are subclasses of the new Craft 6 classes, not the same class under another name. Craft hands you the new class, CraftCms\Cms\Field\Matrix. So $field instanceof craft\fields\Matrix is false. With a type hint you're luckier: that one throws an error you'll see.
Fix: import the Craft 6 classes:
// Before
use craft\fields\Matrix;
use craft\elements\Entry;
use craft\base\FieldInterface;
// After
use CraftCms\Cms\Field\Matrix;
use CraftCms\Cms\Entry\Elements\Entry;
use CraftCms\Cms\Field\Contracts\FieldInterface;
The same goes for the other field types, ElementInterface, User, EntryType and GeneralConfig.
2. Class names written as strings point nowhere
What you see: code that sniffs for an optional plugin takes the "not installed" branch even though the plugin is right there.
Why: a check like is_a($field, 'craft\\ckeditor\\Field') is just a string. Imports, your IDE and static analysis all skip it. In Craft 6 the class is CraftCms\Ckeditor\Field, and a case-sensitive str_contains($class, '\\ckeditor\\') misses the capital C.
Fix: search your code for 'craft\\ and for namespace fragments in strings. Update the names, and compare lowercased strings when you only want to know which package a class comes from.
3. A constant became an enum, and the comparison is always false
What you see: behaviour that depends on a type silently takes the other path. In my case, a single without a title was labelled with its slug instead of its section name.
Why: in Craft 6 some values that used to be strings are now PHP enums. A section's type is SectionType::Single, not 'single'. So $section->type === Section::TYPE_SINGLE compares an enum with a string and is never true. PHP doesn't complain about that.
Fix:
use CraftCms\Cms\Section\Enums\SectionType;
if ($section->type === SectionType::Single) { … }
Static analysis found this one, not me (more on that below).
4. securityKey is gone, and anything signed with it signs nothing
What you see: a feature that relies on a signed token turns itself off, or worse, stops checking.
Why: Craft 6 uses Laravel's APP_KEY. The general config no longer has a securityKey, and through the adapter it reads as an empty string. Code that signs or verifies something with it gets an empty key and doesn't fail.
This one got my own plugin. Component Check signs the markers it puts around Matrix blocks, so it can compare each block with its snapshot. With an empty key, every run quietly fell back to whole-page checks. The result was green, but no block had been compared at all.
Fix: use config('app.key'), and say "APP_KEY" in your error messages.
5. transform() gives you a picture, not the asset
What you see: images that look fine on the front end, until you turn on debug mode and the template throws an error.
Why: asset.setTransform() is deprecated, and the obvious replacement, asset.transform(), doesn't return the asset. It returns a small result object: URL, width, height and file details, and that's all. Call getSrcset() or alt on it and normal Twig just prints nothing. Strict Twig, which you get with APP_DEBUG=true, throws.
Fix: keep the asset and the transform result apart:
{% set image = block.heroImage.one() %}
{% set size = { width: 1200, height: 600, mode: 'crop' } %}
{% set resized = image ? image.transform(size) : null %}
<img src="{{ resized.url }}"
srcset="{{ image.getSrcset(['400w', '800w', '1200w'], size) }}"
width="{{ resized.width }}" height="{{ resized.height }}"
alt="{{ image.alt }}">
And test your templates with APP_DEBUG=true at least once.
6. Craft 5.12's MCP code registers nothing
What you see: your plugin's tools are simply missing from Craft's MCP server. No warning anywhere.
Why: Craft 5.12 brought an MCP server, and plugins could add tools to it through craft\services\Mcp. Craft 6 still has an MCP server, but under a new API (CraftCms\Cms\Mcp). Plugins that carefully wrote if (class_exists(\craft\services\Mcp::class)) now skip the whole thing, and that check was supposed to make them safe.
Fix: register through Craft 6's registries and events:
use CraftCms\Cms\Mcp\CapabilityRegistry;
app(CapabilityRegistry::class)->register(MyTools::class);
Instructions go through the CollectingAdminInstructions and CollectingServerInstructions events. Also note that tool names in Craft 6 use underscores (info_get, content_model_audit), so myplugin.results becomes myplugin_results.
7. Your control panel JavaScript doesn't load where editors work
What you see: a script or button your plugin adds to the entry editor doesn't appear. Your plugin's own settings pages work fine.
Why: the Craft 6 control panel is a Vue app. The entry editor and Live Preview are Vue pages, and they don't have the Twig page template that plugins used to hook into. Assets registered from that hook never reach them. Older Twig pages, like a plugin's own pages, are now drawn into the app after the page has loaded. So a script that runs once on load can find nothing to attach to, and it won't log an error either.
Fix: register scripts and styles with Craft 6's plugin service, which prints them on every control panel page:
app(\CraftCms\Cms\Plugin\Plugins::class)->addScript($this->handle, $url);
Then write the script so it doesn't assume the page is already there. A small custom element that starts your code when it's connected works on both Craft 5 and 6.
8. The control panel's CSS classes are gone
What you see: buttons that look like plain text, tabs that turn into a row of links, cards without borders.
Why: Craft 5's CSS classes (.btn, .card, the tab markup and others) aren't part of the Craft 6 control panel. Its buttons, tabs, inputs and cards are web components now: <craft-button>, <craft-tabs>, <craft-input>, <craft-card>.
Fix: build your UI from those components rather than copying the old styles into your plugin. You get dark mode for free, and your pages keep up when Craft's design changes. The beta design will change before 6.0, so that matters.
How do you catch these?
Not by clicking around. Most of them pass a quick look. What worked for me:
-
Run PHPStan against Craft 6, not Craft 5. Your plugin's own
vendorfolder probably still has Craft 5 in it. Run the analysis inside a Craft 6 project instead. With DDEV, mount the plugin into the site and runcomposer update && composer checkthere. That's how the enum comparison and the leftover type hints turned up. Tests alone didn't show them. - Compare blocks, not just pages. Take a visual snapshot of your blocks on Craft 5 before you upgrade, and compare against it on Craft 6. Then check that the comparison really happened. After #4, I don't trust a green result until it says what it compared.
-
Turn on
APP_DEBUG=truewhile you test, so Twig is strict and errors show their real message instead of a generic error page. - Read Craft's own lists. The adapter adds a Yii2 Loose Ends utility to the control panel. It lists the old APIs your code still uses, each with a note on what to change. Deprecation Warnings shows the file and line for each one.
A short checklist
- Old class imports swapped for
CraftCms\Cms\…ones. - Class names in strings searched and updated.
- Comparisons with old constants checked for enums.
- Nothing signs or verifies with
securityKey. -
transform()results not used as assets; templates tested withAPP_DEBUG=true. - MCP tools registered through the Craft 6 API, with underscore names.
- Control panel scripts registered through the plugin service, and safe when the page arrives late.
- Control panel UI built from Craft 6 components.
Quick answers
Isn't the Yii2 adapter enough on its own?
It gets you most of the way. It keeps old class names, services and console commands working. But it can't make an old class name equal the new one, bring back a removed setting, or put Craft 5's CSS back. Those are the places to check by hand.
Does craft6-revamp fix any of this?
No. It moves folders, config and environment variables, and it does that well. The issues here are in your code: templates, modules and plugins.
Will PHPStan find all of them?
It found the enum comparison and the leftover type hints. It won't find class names hidden in strings, and it says nothing about JavaScript or CSS. Use it together with a visual comparison and a click through the control panel with the browser console open.
Should I wait for Craft 6.0.0 before checking my site?
You don't need to upgrade a live site during the beta. But looking for these issues now, in a copy of the site, is cheap, and it tells you how big the real upgrade will be.
Originally published on b10k.nl. I'm Bohdan, a freelance Craft CMS developer in the Netherlands. Want to know what your site needs for Craft 6? Start with a Craft 6 readiness check.
Top comments (0)