控制器子目录? [英] Controller subdirectories?

查看:34
本文介绍了控制器子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Symfony2 应用程序的子目录中隔离一些控制器.类似的东西:

I would like to isolate some controllers in a subdirectory in my Symfony2 app. Something like that:

route:
  resource: "@MyBundle/Controller/Admin/"
  type:     annotation
  prefix:   /admin/

在这个目录中有 6 个控制器类.我可以单独导入这些,但不实用...

In this directory there is 6 controller class. I can import these separatly but it's not practical ...

感谢您的帮助.

推荐答案

我使用这个,其中包括该文件夹中的每个控制器:

I use this which includes every controller in that folder:

core:
  resource: "@AppCoreBundle/Controller"
  type: annotation

相同的代码适用于子文件夹:

The same code applies to subfolders:

core_admin:
  resource: "@AppCoreBundle/Controller/Admin"
  type: annotation

在 Controller 文件夹中创建子文件夹来拆分公共控制器和管理控制器是完全可以的.

It's perfectly okay to create subfolders inside the Controller folder to split your public and admin controllers.

当然,您可以将它们一个一个地包含在内,但这非常乏味.

Of course you could include each of them one by one instead, but that's extremely tedious.

这篇关于控制器子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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