Reputation: 2710
In config.yml
, I see root element such monolog
, web_profiler
. Are those services that can be configure in service.yml
instead? In the other way, my service that defined in service.yml
, are there possible to defined in config_dev.yml
, config_prod.yml
instead?
What is the difference in term of structure of service.yml
, config.yml
and the way framework interact with it?
Upvotes: 3
Views: 622
Reputation: 359
The difference is that inside the config*.yml files, the so called semantic configuration takes place. Every bundle can expose such a semantic configuration. The services.yml file instead is used to define services of your bundle.
So under monolog
in the config.yml you configure the respective bundle. You don't define a service. The services of the monolog
bundle are defined inside that bundle and you don't have to know about that.
If you have paid attention, you will have noticed that inside the services.yml the section starts with services
and not the name of your bundle. That's because inside the services
section you define services.
But to answer your second part of the question: Yes you can copy the contents of services.yml to config.yml but the strength of this separation is, that each bundle comes with a service configuration but you have one central config*.yml file for every bundle. Therefore it wouldn't be wise to copy your contents to this central file.
Upvotes: 0
Reputation: 1500
config.yml is global configuration which includes service.yml.
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
There is only logical difference. All parameters, which placed in your service.yml, you can place in config.yml
Upvotes: 1