I generated a bundle and set it to use annotations for config files. But I find that in Resources/config/services.xml
, its still XML? Perhaps it because I cant configure services using annotations? If so how can I make it use yml if thats the case? I could just add a YML file but I dont suppose it will be detected?
Asked
Active
Viewed 1,891 times
1

Jiew Meng
- 84,767
- 185
- 495
- 805
1 Answers
2
Your assumption that you can't define a service using Annotations is correct. You need to have either a services.xml
or services.yml
under Resources/config
for the bundle.
Check out the answers to this question, it covers how to define a service using both xml
, yml
and through a config.yml
import.
I've also written an answer here on the basics of defining a service.
-
So I need to create an Extension Class just to let symfony know a service.yml is there? I can't just put the config in `app/config/config.yml` like shown in the docs? – Jiew Meng Dec 04 '11 at 23:50
-
You can just put the whole service definition into `app/config/config.yml` or you can import a `services.yml` file from your bundle into the main `config.yml`. OR What the `Extension` class does is stop you from having to do the import `services.yml` into `config.yml` manually, instead symfony will be able to autoload it (it's good if your bundle is standalone and you don't want people to have to activate your bundle's services in any way). – Kasheen Dec 05 '11 at 09:39