Reputation: 31548
I am using annotations to define routes in controllers and I have 15 controllers. All are executed by /path1
, /path2
.
Is there any way that in all those controller , I can access them via /admin/path1
and /admin/path2
?
I don't want to enter that by changing each file.
Can I do that from a single location? I mean the whole bundle should open via /admin
and then their respective paths.
Upvotes: 8
Views: 8073
Reputation: 722
If you want to prefix specific controller DevController for example and have something like:
myproject.com/dev/test
in your Controller add the following Route annotation as in example:
/**
* @Route("/dev")
*/
class DevController extends Controller{
/**
* @Route("/test")
*/
public function testSavingAction(){
return new Response();
}
....
Upvotes: 2
Reputation: 44841
Use this in routing.yml
:
Admin:
resource: "@AdminBundle/Controller"
type: annotation
prefix: /admin
Upvotes: 6
Reputation: 31548
try this
# app/config/routing.yml
acme_hello:
resource: "@AcmeHelloBundle/Resources/config/routing.yml"
prefix: /admin
or if using annotations
resource: "@AcmeHelloBundle/Controller"
type: annotation
prefix: /admin
Upvotes: 15
Reputation: 17976
Just define the annotation for your Class (not for method)
/**
* @Route("/blog")
*/
Upvotes: 4