Symfony News

New in Symfony 3.3: Import config files with glob patterns

Pierre du Plessis

Contributed by
Pierre du Plessis
in #21270.

The Symfony DependencyInjection component is pretty flexible in the way you can import other files in your application configuration. You can for example mix config formats when needed:

1
2
3
4
5
6
7
# app/config/config.yml
imports:
    - { resource: '../common/config.yml' }
    - { resource: 'dynamic-config.php' }
    - { resource: 'parameters.ini' }
    - { resource: 'security.xml' }
    # ...

You can also import entire directories to load all the resources inside them:

1
2
3
4
5
# app/config/config.yml
imports:
    - { resource: '../common/' }
    - { resource: 'acme/' }
    # ...

In Symfony 3.3 we improved this feature to support importing config files with glob patterns. This will simplify your configuration files because you can now import lots of different resources in a compact way:

1
2
3
4
5
6
7
# app/config/config.yml
imports:
    - { resource: "*.yml" }
    - { resource: "common/**/*.xml" }
    - { resource: "/etc/myapp/*.{yml,xml}" }
    - { resource: "bundles/*/{xml,yaml}/services.{yml,xml}" }
    # ...

Be trained by Symfony experts - 2017-02-20 Paris - 2017-02-20 Paris - 2017-02-22 Paris


About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Find us on Twitter

Find us on Facebook

ADS