Add admin Routes for a Sylius Resource
Ask the user for the ModelName if not provided.
Prerequisites:
- Model exists as a Sylius Resource (
/sylius-app:add-model) - Grid is configured (
/sylius-app:add-grid)
1. Add the routes
Edit config/routes/admin.yaml (create if missing). Append a new resource block:
app_admin_{model_snake}:
resource: |
alias: app.{model_snake}
section: admin
templates: '@SyliusAdmin/shared/crud'
except: ['show']
redirect: update
grid: app_admin_{model_snake}
vars:
all:
subheader: app.ui.manage_{model_snake_plural}
index:
icon: 'tabler:list'
type: sylius.resource
prefix: /admin
The top-level key and the grid: value must match the grid name from /sylius-app:add-grid. Remove except: ['show'] to enable the show route (also requires a show template).
2. Ensure the file is imported
config/routes/*.yaml files are auto-loaded by Symfony. Usually nothing to do — verify via §3 before adding any import.
3. Clear cache
bin/console cache:clear
4. Verify
-
bin/console debug:router | grep {model_snake}lists 4 routes (_index,_create,_update,_delete) — plus_showif the show action was enabled
Next steps
- Add admin menu entry →
/sylius-app:add-menu - Add translations for
app.ui.manage_{model_snake_plural}in the project's default translations file (runbin/console debug:container --parameter=kernel.default_localeto get the locale)