Skip to content
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

Environment configuration model TOOL-14 #1

Merged
merged 3 commits into from
Jan 4, 2018
Merged

Environment configuration model TOOL-14 #1

merged 3 commits into from
Jan 4, 2018

Conversation

dangron
Copy link
Contributor

@dangron dangron commented Jan 4, 2018

https://space48.atlassian.net/browse/TOOL-14

A small domain model to represent the Magento configuration and Magento environments, so we can set different values for different passed environment identifier to reduce the overhead of setting things like test credentials, base url's and the like.

@punkstar
Copy link
Contributor

punkstar commented Jan 4, 2018

We used https://github.com/punkstar/mageconfigsync for Magento 1. Support for Magento 2 is in there but we haven't used it. There's also an open quality of life issue that we'd need to resolve before using it seriously: punkstar/mageconfigsync#19

Not currently suggesting that we use it, but ideas like storing the configuration in YAML could be brought across from it as we did find that particularly useful.

(I don't have access to JIRA yet so apologies if I've missed the point 😁)

@dangron
Copy link
Contributor Author

dangron commented Jan 4, 2018

@punkstar thanks for the tip, your module seems safer, the idea with this is to have a file dropped in by composer at app/etc/environment-config.php that would just return a new EnvironmentConfigurationValues, I wrote a similar module at another place which needed the flexibility of being able to execute php code when collecting values, this was quite useful but in practice configuration like this should be static and boring!

@dangron
Copy link
Contributor Author

dangron commented Jan 4, 2018

@punkstar I will give your module a whirl, thanks for letting us know, and thanks for making my first Space48 code totally useless 😂

@punkstar
Copy link
Contributor

punkstar commented Jan 4, 2018

@DanK00 Sorry! 😂 @tgerulaitis and I are in two minds about whether we even need mageconfigsync for M2 due to Magento needing certain things to be defined in env.php for magento setup:upgrade --keep-generated to work with our Bamboo builds. We're currently planning on just bunging everything in there and switching it out between environments. We're still new at deploying Magento 2 so any experience you have there will likely trump ours!

@iainhubbard
Copy link

There is also M2.2 dump config which puts a bunch of "stuff" in config.php, primarily to allow DB less frontend compilation. I have to admit that we have not put much effort into finding out exactly what can practically be serialised into config.php yet

@dangron
Copy link
Contributor Author

dangron commented Jan 4, 2018

@tgerulaitis
Copy link

One thing to keep in mind if you're using app/etc/config.php and app/etc/env.php is that Magento 2 likes to read those files in and write them back out (I think this happens during bin/magento setup:upgrade, but I haven't confirmed that). This makes it difficult to use those files for any additional processing, such as fetching the configuration values from somewhere else, as the changes to the files might just get replaced with an array of the current values (Thanks, Magento!).

Another potential avenue that looks interesting, but I haven't explored personally, is using environment variables for environment specific configurations. Starting with Magento 2.2, you can just set environment variables with specific format names to get Magento to update its config: http://devdocs.magento.com/guides/v2.2/config-guide/deployment/pipeline/example/environment-variables.html

@dangron
Copy link
Contributor Author

dangron commented Jan 4, 2018

I still think I am happiest setting these values in PHP. Some method of using environment variables in the linked article above seems like the most appropriate approach but something needs to be built on top of it to make it developer friendly. Until such a time I am going to use this package 😝

@dangron dangron merged commit d317d7c into master Jan 4, 2018
@dangron
Copy link
Contributor Author

dangron commented Jan 4, 2018

@punkstar @iainhubbard @tgerulaitis

After some fiddling around with custom configuration files this afternoon I learned that 2.2.0 has removed the custom config file pool feature. 😩

    /**
     * Initial files for configuration
     *
     * @var array
     * @deprecated 100.2.0 Magento does not support custom config file pools since 2.2.0 version
     */
    private $initialConfigFiles = [
        self::DIST => [
            self::APP_CONFIG => 'config.dist.php',
            self::APP_ENV => 'env.dist.php',
        ],
        self::LOCAL => [
            self::APP_CONFIG => 'config.local.php',
            self::APP_ENV => 'env.local.php',
        ]
    ];

@dangron dangron deleted the feature/model branch January 30, 2018 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants