Hi Lukas, Lukas Kahwe Smith wrote: > Hi, > > I have a problem where I am not sure how to best structure this using > the service container yaml syntax. > > Take for example this configuration for production: > > services: > db: > class: api_db_doctrine > arguments: > dsn: mysql://infocube:l...@localhost/infocube > options: > models_path: localinc/api/model > name: default > charset: utf8 > log: false > shared: true > > Should look like the following during development: > > services: > writer: > class: Zend_Log_Writer_apiFirebug > arguments: [] > shared: true > logger: > class: Zend_Log > arguments: [...@writer] > shared: true > log: > class: api_log > arguments: [...@logger, DEBUG, true] > shared: true > db_logger: > class: api_db_doctrine_log > arguments: [...@log] > shared: true > db: > class: api_db_doctrine > arguments: > dsn: mysql://t...@localhost/test > options: > models_path: localinc/api/model > name: default > charset: utf8 > log: @db_logger > shared: true > > --- > > Now what I obviously want is to keep the differences to a minimum. > > So ideally I would do a default service definition like so: > > # parameters.yml > parameters: > db_logger: false > > #services.yml > imports: > parameters: { resource: parameters.yml, class: > sfServiceContainerLoaderFileYaml } > > services: > db: > class: api_db_doctrine > arguments: > dsn: mysql://infocube:l...@localhost/infocube > options: > models_path: localinc/api/model > name: default > charset: utf8 > log: %db_logger% > shared: true > > Now for the development setup I would have something like: > > # services_dev.yml > imports: > default: { resource: services, class: > sfServiceContainerLoaderFileYaml } > > services: > writer: > class: Zend_Log_Writer_apiFirebug > arguments: [] > shared: true > logger: > class: Zend_Log > arguments: [...@writer] > shared: true > log: > class: api_log > arguments: [...@logger, DEBUG, true] > shared: true > db_logger: > class: api_db_doctrine_log > arguments: [...@log] > shared: true > > Now how do I get @db_logger into the services.yml definition?
It was not possible before today, as a parameter could not be a reference to a service. As of r23506, this is possible, so your problem is solved. In dev, the db_logger parameter can be a reference to the db_logger service: parameters: db_logger: @db_logger Fabien > > Not sure what the best approach is .. maybe I need to move the loading > of the parameters.yml file out of the services.yml and into my > initialization code that makes the sfServiceContainer instance. As in > decide based on the environment what services and what parameters yaml > to load. > > regards, > Lukas Kahwe Smith > m...@pooteeweet.org > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---