Symfony 4-两个目录中的控制器 [英] Symfony 4 - controllers in two directories
本文介绍了Symfony 4-两个目录中的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我使用Symfony4。我希望Symfony在两个目录(A和B)中搜索控制器。
In my application, I use Symfony 4. I want Symfony to search for controllers in two directories: A and B. I found something like this:
controllers:
resource: '../src/DirectoryA/Controller/'
type: annotation
,但仅适用于一个目录。如何让Symfony在两个目录中搜索控制器?
, but it only works for one directory. How can I have Symfony to search for controllers in two directories?
问候
推荐答案
在您的 config / services.yaml
App\DirectoryA\Controller\: # assuming you have namespace like that
resource: '../src/DirectoryA/Controller'
tags: ['controller.service_arguments']
App\DirectoryB\Controller\: # assuming you have namespace like that
resource: '../src/DirectoryB/Controller'
tags: ['controller.service_arguments']
这将为服务参数添加下一个目录。多数民众赞成在基础上回答您的问题,在目录中,您发布的是路由文件,类似
This will add next directory for service arguments. Thats answers your questions based In directory, what you have posted is routing file, in there would be similiar
controllers_a:
resource: '../src/DirectoryA/Controller/'
type: annotation
controllers_b:
resource: '../src/DirectoryB/Controller/'
type: annotation
这篇关于Symfony 4-两个目录中的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文