1
votes

I register Symfony2 controllers as a services and I use dependency injection by constructor. Controllers isn't child of main Controller class. When I use routing by routing.yml, that's OK, but when I want use @Route annotation, services aren't inject to controller constructor.

It's there any way how I can use controllers as a service with DI and @Route annotation together?

1

1 Answers

2
votes

You should just add @Route annotation to your controller with a service parameter:

/** @Route("/", service="your.controller.service.id") */
class YourController