Symfony2: Multi-level parameters in YML

3.3k Views Asked by At

Here is what I want to do. I've got some yml file like...

My custom yml file :

# app/config/sv_parameters.yml
parameters:
  sv_email:
    debug: "[email protected]"
    admin: "[email protected]"
    ...

The config.yml file, importing my custom params :

# app/config/config.yml
imports:
  - { resource: sv_parameters.yml }
...

The config_dev.yml, importing the config.yml, and using a sub-parameter of my custom yml file :

# app/config/config_dev.yml
imports:
- { resource: config.yml }

swiftmailer:
  delivery_address: "%sv_email.debug%"

But, when I clear:cache :

You have requested a non-existent parameter "sv_email.debug".

I know in PHP multi-level parameters are arrays. But does that mean we can access them in pure YML ?

I could write my sv_email parameters inline, but that's not as clean as multi levels..

1

There are 1 best solutions below

4
On

This is not possible to achieve in YML.
You have to move this nested variable to the upper level and then - include it in both needed places.