Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controller subdirectories?

Tags:

symfony

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.

like image 870
SebLou Avatar asked Oct 21 '22 19:10

SebLou


1 Answers

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.

like image 50
Pier-Luc Gendreau Avatar answered Oct 29 '22 00:10

Pier-Luc Gendreau