4.4 Routing Migration
This step updates routing configuration to match Sylius 2.0 conventions. The main changes are switching to shared
template sets and replacing deprecated vars
configuration with the new Twig Hooks system.
When to skip this step:
Your plugin doesn't use Sylius resource routing (no
type: sylius.resource
)You don't reference
@SyliusAdmin
or@SyliusShop
templates in routing
When to do this step:
You use Sylius CRUD routes with template references
1. Update Admin Route Templates
In config/routes/admin.yaml
, update the routing configuration:
Before (Sylius 1.x):
plugin_admin_terms:
resource: |
alias: plugin.terms
section: admin
templates: "@SyliusAdmin\Crud"
redirect: update
grid: plugin_terms
vars:
all:
subheader: plugin.ui.manage_terms
templates:
form: "@Plugin/admin/terms/_form.html.twig"
index:
icon: 'check circle outline'
type: sylius.resource
After (Sylius 2.0):
plugin_admin_terms:
resource: |
alias: plugin.terms
section: admin
except: [show]
templates: "@SyliusAdmin\shared\crud"
redirect: update
grid: plugin_terms
vars:
all:
hook_prefix: 'plugin.admin.terms'
type: sylius.resource
Key changes:
templates: "@SyliusAdmin\Crud"
→templates: "@SyliusAdmin\shared\crud"
Add
except: [show]
if you don't need the show actionRemove
vars.all.subheader
andvars.{action}.subheader
- no longer usedRemove
vars.all.templates.form
- replaced by Twig HooksRemove
vars.all.icon
andvars.{action}.icon
(e.g.,vars.index.icon
) - no longer usedAdd
vars.all.hook_prefix
- for Twig Hooks integration
2. Update Shop Route Templates
If you have Shop routes using Sylius templates, update them similarly:
Before:
plugin_shop_product:
resource: |
alias: plugin.product
section: shop
templates: "@SyliusShop\product"
type: sylius.resource
After:
plugin_shop_product:
resource: |
alias: plugin.product
section: shop
templates: "@SyliusShop\shared\product"
type: sylius.resource
Key change: @SyliusShop\[name]
→ @SyliusShop\shared\[name]
3. Validate Routes
Check that routes load correctly:
vendor/bin/console debug:router
You should see your routes listed without errors. Verify that routes match your expectations (especially if you used except
).
Note: Form templates and other customizations will be migrated to Twig Hooks in a later step (Step: Template Migration).
Last updated
Was this helpful?