Avoiding Route Collision in eZ Platform

eZ Platform boils down to a set of Symfony bundles that give you a nice way of managing content for your users. With these bundles, eZ reserves some routing paths for internal or admin use, paths that you might want for your own app. If you ever run across a path you want to use for your app, and not break an internal eZ feature, there is a simple solution: change the path config.

Changing the path

Looking at the eZ Platform search route, we see that eZ has reserved /search for their internal use. I want to use use /search for my custom search endpoint. To fix, we’ll just redefine the route.

vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/config/routing.yml

The definition for the search route found in the admin bundle:

ezplatform.search:
    path: /search
    methods: ['GET']
    defaults:
        _controller: 'EzPlatformAdminUiBundle:Search:search'

app/config/routing.yml

In your routing file use the same name with a different path:

ezplatform.search:
    path: /adminsearch
    methods: ['GET']
    defaults:
        _controller: 'EzPlatformAdminUiBundle:Search:search'

And you’re done! eZ is very good at ensuring they use internal Symony routing when generating urls for a page, so you’re safe to simply redefine the route to avoid route collosion in eZ Platform.