在symfony 4中路由 [英] routing in symfony 4
问题描述
我想这样路由我的 app 和 api :
app:
resource: ../src/Controller
type: annotation
prefix: /
api:
resource: ../src/Controller/Api
type: annotation
prefix: /api
第一季度:我应该在哪里写?在config/routes/annotations.yaml
或
config/routes.yaml
.
Q1: Where should I write this? in config/routes/annotations.yaml
or
config/routes.yaml
.
第二季度:这两个文件之间的区别是什么?
Q2: what is different between this two file and which one is used for?
推荐答案
文件config/routes/annotations.yaml
可能是Flex在应用注释配方时创建的.我不确定100%,但是当您要删除注释包时,它也会删除此文件.
The file config/routes/annotations.yaml
was probably created by a flex when applying annotations recipe. I am not 100% sure, but when you want to delete the annotations bundle it will also remove this file.
但是对我来说,将所有注释路由导入放入config/routes/annotations.yaml
文件是有意义的,因为它们仅依赖于此包.
But it makes sense to me to put all annotation route imports into config/routes/annotations.yaml
file, because they just depend on this package.
您应放入config/routes.yaml
文件的其他路由.
Other routes you should put into the config/routes.yaml
file.
这篇关于在symfony 4中路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!