2 Fix Container Compilation
This step ensures your Symfony service container compiles successfully after updating dependencies to Sylius 2.0.
When to skip this step:
Container already compiles without errors after composer update
When to do this step:
cache:clear
command fails with errorsService not found errors appear
Deprecated service warnings
Philosophy
Priority order:
✅ Fix what you can - If service has a replacement in UPGRADE-2.0.md → use the new service ID
⏳ Comment out what you can't - Only comment out code that:
Has no replacement (removed feature)
Is too complex to fix now
Will be migrated in later steps (UI events, API)
Don't comment out services that just need a new ID! Check UPGRADE-2.0.md first.
1. Test Container Compilation
vendor/bin/console cache:clear
If this succeeds → Skip to next step.
If you see errors → Continue with this guide.
2. Fix Missing Sylius Services
If you see errors like:
Service "sylius.xyz" not found
Service "sylius.abc" has been removed
Check the Sylius UPGRADE file:
View online: Sylius 2.0 UPGRADE Guide
Or locally:
vendor/sylius/sylius/UPGRADE-2.0.md
Search for the service name in the file. There's a large table showing:
Which services were removed
What they were replaced with
Migration instructions
Common service changes:
Many
sylius.repository.*
services unchangedSome
sylius.factory.*
services renamedGrid and resource services restructured
UI event system removed (replaced by Twig Hooks)
Action:
If replacement exists:
Find the new service ID in UPGRADE-2.0.md
Search for old service ID in your code:
grep -r "old.service.id" src/ config/
Replace old service ID with new one in all files
Re-run
cache:clear
to verify
If no replacement exists:
Service was removed (e.g., UI events)
Go to Step 3 and comment it out with TODO
Will be migrated in later steps
3. Comment Out What Cannot Be Fixed Now
Only comment out code that:
Has no replacement (removed Sylius features)
Is too complex to fix at this stage
Will be properly migrated in later steps
Don't comment out services that just need a new ID - fix them in Step 2!
What to Comment Out:
1. sylius_ui
event configurations
In Extension class (src/DependencyInjection/*Extension.php
):
public function prepend(ContainerBuilder $container): void
{
// TODO: Migrate to Twig Hooks in Step (Templates)
/*
$container->prependExtensionConfig('sylius_ui', [
'events' => [
'sylius.admin.layout.javascripts' => [
'blocks' => [
'your_plugin_key' => [
'template' => '@YourPlugin/admin/_javascripts.html.twig',
],
],
],
],
]);
*/
}
In config files (config/packages/sylius_ui.yaml
):
# TODO: Migrate to Twig Hooks in Step(Templates)
# sylius_ui:
# events:
# ...
2. API service definitions (will be migrated in Step 9)
If you see errors related to API Platform services, comment them out:
<!-- TODO: Migrate to API Platform 4.x in Step API -->
<!--
<service id="app.api.data_provider">
...
</service>
-->
3. Any other broken code
If something else prevents container compilation, comment it out:
// TODO: Fix in appropriate step - investigate which step handles this
// ... broken code ...
Important: Always add TODO
comments explaining:
What needs to be fixed
In which migration step it should be fixed
Why it was commented out (optional)
4. Validate Container Compilation
vendor/bin/console cache:clear
Expected result: Command succeeds without errors.
If you still see errors:
Read the error message carefully
Check UPGRADE-2.0.md for the specific service/class
Comment out the problematic code (add TODO comment)
Try
cache:clear
againRepeat until container compiles
Goal: Get the container to compile. You can fix specific features in later steps.
Last updated
Was this helpful?