在symfony 4中路由 [英] routing in symfony 4

查看:141
本文介绍了在symfony 4中路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样路由我的 app api :

app:
    resource: ../src/Controller
    type: annotation
    prefix: /

api:
    resource: ../src/Controller/Api
    type: annotation
    prefix: /api

第一季度:我应该在哪里写?在config/routes/annotations.yamlconfig/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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆