更新时间:2022-01-18 21:24:36
您链接的问题实际上非常相关.你问的和其他人一样:
The question you linked to is actually very relevant. You are asking just the same as the other guy:
但是如果你在控制器中将路由定义为注解,你怎么能做到这一点呢?在这种情况下,有没有办法指定这条路线的顺序?
But how can you do this if you define your routes as annotations in your controllers? Is there any way to specify the ordering of this routes in this case?
在 Symfony 4 中,你的 config/routes.yaml
可能是空的,config/routes/annotations.yaml
可能是这样的:
In Symfony 4, your config/routes.yaml
is probably empty and config/routes/annotations.yaml
probably like this:
controllers:
resource: ../../src/Controller/
type: annotation
你可以用这个 – 替换上面的 YAML;请注意顺序确实很重要:
You can replace the above YAML with this – notice that the order does matter:
Video:
resource: App\Controller\VideoController
type: annotation
User:
resource: App\Controller\UserController
type: annotation
然后 site.com/videos
首先到达视频控制器.
Then site.com/videos
reaches the video controller first.