Skip to content

New in Symfony 3.3 Import config files with glob patterns

February 16, 2017 Published by Avatar of Javier Eguiluz\ \ \ '" class="ui-avatar d-inline-block object-fit-cover ui-avatar-with-border me-2"> Javier Eguiluz

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}" }
 # ...

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.

Tartare2240 said on Feb 16, 2017 at 11:30

Very useful if you have a folder as configuration, thanks !

jogm said on Feb 16, 2017 at 13:06

A truly useful feature! Symfony 3.3 is becoming more and more interesting.

Almahdi TRIMECH Certified said on Feb 17, 2017 at 20:28

I'm just waiting for the 3.3 symfony version ! Very Good ! Thanks

Matt Holbrook-Bull said on Mar 25, 2017 at 08:28

Awesome, finally we can start tidying the configuration mess!

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /