Reputation: 95
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/
In this directory there is 6 controller class. I can import these separatly but it's not practical ...
Thanks for your help.
Upvotes: 5
Views: 10308
Reputation: 4144
You don't need to do anything special, the code below includes subdirectories like
/Controller/admin/
for example.
app:
resource: "@AppBundle/Controller/"
type: annotation
Upvotes: -1
Reputation: 13814
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
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.
Upvotes: 10
Reputation: 31548
Its not good practice to do like that. Why can you make the extra bundle if you really like to isolate the stuff.
Then you can make them as service and access from where ever you want
See here http://symfony.com/doc/2.0/cookbook/controller/service.html
Upvotes: -6