@route annotation overriding another route

I have a staticController with actions for the following link examples:

/ register / output

this is an example annotation:

/** *@Route("/imprint", name="user.static.imprint") */ 

And now I have the following annotation for linking to other pages with dynamic link names:

 /** *@Route("/{area}", requirements={"id" = "!imprint"}, name="user.area.index") */ 

I am using the path () function in a branch to create links.

The generated link / fingerprint ist is now routed to the second annotation. How can I avoid this problem?

Many thanks.

+4
source share
1 answer

The second route matches the same pattern as the first and interferes with it, so you need to put priority first.

Somewhere in your project, you import these two controller routes in the form of annotations (possibly /app/config/routing.yml ). It looks something like this:

 bar_route: resource: "@FooBundle/Controller/BarController.php" type: annotation prefix: / 

Currently, most likely the second controller import is higher. Cancel it.

+3
source

Source: https://habr.com/ru/post/1393649/


All Articles