New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify configuration registration #21173
Comments
In 2.8 we introduced a feature to load recursively all config files in directories. Would that help you? # Before Symfony 2.8
imports:
- { resource: acme/parameters.yml }
- { resource: acme/security.yml }
- { resource: acme/services.yml }
# In Symfony 2.8
imports:
- { resource: acme/ } |
@javiereguiluz interesting feature I didn't know about it! But nope, there is two issues:
|
Move the files to load automatically to a dedicated folder inside
Change your strategy and use |
@javiereguiluz it's doable, but I'm not really fond of it, it requires too much tweaking with conventions I'm not happy with where I would like it to "just works". If you have:
This looks really annoying to me, I want But I understand it may be too opinionated to be integrated in the core. I'm just making the suggestion and see what people think of it. |
@theofidry I totally understand you. It's doable ... but annoying. Let's wait for more opinions! |
You can detect if it's a Glob because there are no filenames with |
You could make a convention that if the file name (minus |
@iltar not sure to have understood what you mean, could you elaborate? |
Requirement: The first key of the file has to match the extension name, so that same as it is now, but just a fail safe for autodetection. |
ah yeah that's what I do but not all my files requires an extension (if the default suffice, or if there is no extension, just services – yeah I have extension and service in the same file) and that requires to parse the file content before loading them, which is far from ideal as well. |
Load the content, parse the yaml, then merge the arrays or skip it if it failed |
Hm actually when I decide if a file is loaded or not, I just choose the appropriate name, having the content matching is just a convention but it's not what I'm basing the loading on. For example if I want to add a file |
…files (pierredup) This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] Use glob pattern to load config files | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21173 | License | MIT | Doc PR | - This relates to #21173, but I'm not sure if it completely fixes the issue. This allows to use a glob pattern to load config files, which makes the following possible: ``` # config.yml imports: - { resource: "*.yml" } - { resource: "folder/*.yml" } - { resource: "/etc/myapp/*.{yml,xml}" } ``` It can also be used in a container extension, if a bundle uses a lot of configs: ``` $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('*.yml'); $loader->load('routing/*'); ``` Commits ------- 519180e Use glob pattern to load config file
I guess it's not everyone, but I personally use a lot of configuration files. I like to split them when it makes sense and avoid having config files that are too big. On my last 3 good sized projects (not all from me actually) the average was ~50 files.
I personally find very cumbersome to have to manually include them via
config*.yml
files, so I've done a small locator which register my config files automatically. It works as follow:routing
andparameters.dist
and other are environment specificSo you basically have the following:
I would like to suggest to have that feature directly in the core (I can work on it), WDYT?
/cc DX master @weaverryan
The text was updated successfully, but these errors were encountered: