Skip to content

Configuration files organization when using the full-stack framework #3680

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

Closed
fabpot opened this issue Mar 14, 2014 · 15 comments
Closed

Configuration files organization when using the full-stack framework #3680

fabpot opened this issue Mar 14, 2014 · 15 comments
Labels
actionable Clear and specific issues ready for anyone to take them.

Comments

@fabpot
Copy link
Member

fabpot commented Mar 14, 2014

The default way to store configuration files in the Symfony standard edition was choosen for its simplicity: one file per environment. But that's just the default way.

When your configuration files grows, you might want to adopt a slightly different strategy where you create for instance one configuration file per bundle. But as it's definitely not needed by default (default configuration is quite short), I think that a cookbook about different ways to store your configuration might help people think about the best way for their project.

See symfony/symfony-standard#599 for the discussion that triggered this ticket.

@wouterj
Copy link
Member

wouterj commented Mar 17, 2014

This should be documented in a new cookbook article in the "Configuration" subject (we might want to split that subject into 2 subjects, but that's not related to this issue)

@lavoiesl
Copy link
Contributor

lavoiesl commented Jun 2, 2014

Following the same idea, I came up with a full implementation of a DirectoryLoader and with documented examples on how to separate everything.

See https://github.com/wemakecustom/DirectoryLoaderBundle and https://github.com/wemakecustom/symfony-kickstart/tree/master/dist for the final tree:

app
├── AppKernel.php
└── config
    ├── config
    │   ├── common
    │   │   ├── assetic.yml
    │   │   ├── doctrine.yml
    │   │   ├── framework.yml
    │   │   ├── security.yml
    │   │   ├── swiftmailer.yml
    │   │   └── twig.yml
    │   ├── dev
    │   │   ├── assetic.yml
    │   │   ├── framework.yml
    │   │   ├── monolog.yml
    │   │   ├── swiftmailer.yml
    │   │   └── web_profiler.yml
    │   ├── prod
    │   │   ├── assetic.yml
    │   │   ├── doctrine.yml
    │   │   └── monolog.yml
    │   └── test
    │       ├── framework.yml
    │       ├── swiftmailer.yml
    │       └── web_profiler.yml
    ├── config.yml
    ├── parameters
    │   ├── common
    │   │   ├── core.yml
    │   │   ├── i18n.yml
    │   ├── dist
    │   │   ├── mailer.yml
    │   │   └── security.yml
    │   └── local
    └── routing
        ├── common
        │   └── fos.yml
        └── dev
            ├── common.yml
            ├── configurator.yml
            └── profiler.yml

This also uses directories for parameters with dist/local/common folders, replacing Incenteev’s parameter builder.

If someone likes the idea, I am willing to give a hand with the documentation, improving #3885 or starting another. I would also appreciate some feedback or comments.

@wouterj
Copy link
Member

wouterj commented Jun 2, 2014

If people like the bundle, we can add a little tip box with a link to the bundle in that article after #3885 is merged.

@xabbuh
Copy link
Member

xabbuh commented Jun 3, 2014

I like the idea. But I don't think that this should be put in a bundle. For me, it should be a standalone library which could also be used if you used the components without the full-stack framework.

@cordoval
Copy link
Contributor

cordoval commented Jun 3, 2014

@xabbuh i think Christian is very right here, this should be a library, and try that one to be well decoupled. I think this can rock 👍

@stof
Copy link
Member

stof commented Jun 3, 2014

@lavoiesl
Copy link
Contributor

lavoiesl commented Jun 3, 2014

Both of the loaders are usable as is, but you still need the bundle to register them in Symfony itself.

Do you suggest I create a project for directoryloader-di, directoryloader-routing and directory-bundle ?

@wouterj
Copy link
Member

wouterj commented Jun 3, 2014

Do you suggest I create a project for directoryloader-di, directoryloader-routing and directory-bundle ?

@xabbuh suggested that you should create a DirectoryLoader package with the loaders and a DirectoryLoaderBundle for their integration into Symfony. However, I don't think that is needed: It's a simple bundle and if you want the loaders, just require the bundle!

@lavoiesl
Copy link
Contributor

lavoiesl commented Jun 3, 2014

Yes, that was my idea as well. I will configure the composer.json to be permissive, without requiring symfony-framework.

@lavoiesl
Copy link
Contributor

lavoiesl commented Jun 3, 2014

@xabbuh
Copy link
Member

xabbuh commented Jun 4, 2014

Well, Id rather prefer this to be separated into a library and a bundle. But I don't have too strong feelings with that. But, as @stof pointed out, your loader may be useful for Symfony itself. So, I suggest that you prepare a pull request for this on the Symfony repository.

@lavoiesl
Copy link
Contributor

lavoiesl commented Jun 4, 2014

See @fabpot 's comment saying explicitly he doesn't want it: https://github.com/symfony/symfony-standard/issues/599#issuecomment-37621837

@stof
Copy link
Member

stof commented Jun 4, 2014

@lavoiesl he rejected changing the default structure in symfony-standard. this does not mean he would reject including the DirectoryLoader in the component itself

@lavoiesl
Copy link
Contributor

lavoiesl commented Jun 4, 2014

Good point, I will work on this, thanks.

weaverryan added a commit that referenced this issue Aug 16, 2014
…ook (javiereguiluz)

This PR was merged into the 2.3 branch.

Discussion
----------

[RFR] Added "How to Organize Configuration Files" cookbook

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | 2.3+
| Fixed tickets | #3680

This is just the first draft of a new cookbook. Please, tell me anything that I should add, change or remove. Thanks!

Commits
-------

4241ee5 Removed redundant configuration blocks
68a7d2a Added more suggestions made by @xabbuh
be414e0 Removed the "Directory Loading" section because it doesn't work out of the box
da3e1d0 Fixed the target of one cookbook article link
af5d478 Added suggestions made by @cordoval
4a87cfb Fixed the link to another cookbook article
2a32b23 Added the latest suggestions made by reviewers
d861be3 Added all the suggestions made by reviewers
0520bf1 Firest draft of the "How to Organize Configuration Files" cookbook
@weaverryan
Copy link
Member

The docs PR for this has now been merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them.
Projects
None yet
Development

No branches or pull requests

7 participants