Controller subdirectories?

I would like to highlight some controllers in a subdirectory of my Symfony2 application. Something like that:

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

There are 6 controller classes in this directory. I can import these separately, but it is not practical ...

Thank you for your help.

+4
source share
3 answers

I use this, which includes every controller in this folder:

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

The same code applies to subfolders:

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

It is perfectly normal to create subfolders inside the Controller folder to separate public and administrative controllers.

Of course, you could turn on each of them one by one, but it is very tiring.

+9
source

You do not need to do anything, the code below includes subdirectories such as

 /Controller/admin/ 

eg.

 app: resource: "@AppBundle/Controller/" type: annotation 
0
source

This is a bad practice. Why you can make an extra package if you really like to insulate the material.

Then you can make them as a service and access wherever you want.

See here http://symfony.com/doc/2.0/cookbook/controller/service.html

-5
source

All Articles