phpsymfonyroutesyamlsymfony-3.1

How to change priority in Symfony3 routing.yml


I have the following generic routing on my symfony project as in (routing.yml):

appsite2:
    path:     /{req}/{var}
    defaults: {_controller: AppBundle:Default:index}

However, it overwrites the routing api/doc as:

NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

So how can I change the first routing and put exception for {var}, something like: if({req}/{var} != '/api/doc')?

Note: I already tried to change the order of the 2 routes and it doesn't work.


Solution

  • Fixed it by adding the following regex to exclude the word "doc" as the following :

    appsite2:
    path:     /{req}/{var}
    defaults: {_controller: AppBundle:Default:index}
    requirements:
            var: '^((?!doc).)*$'