4

As of Magento 2.2 it's recommended to add config.php to your source control to facilitate pipeline deployment. I have some questions and issues with this. I'm hoping somebody can share their experience and give me some insights into this recommendation.

A very simplified way to describe the deployment process would be that the Magento build steps are executed in this order:

  1. bin/magento setup:di:compile
  2. bin/magento setup:static-content:deploy
  3. bin/magento setup:upgrade --keep-generated

By adding certain configuration to config.php step #1 and #2 can be executed without a connection to a database and thus on a separate server without turning on maintenance mode. You'll always need a connection to the database for step #3.

In config.php there are 3 arrays that you'll need before you can run step #1 and #2: modules, system and scopes.

I have an issue with adding config.php to my source control because of the modules array. I'll explain why.

In the modules array Magento adds the modules in a specific order determined by the <sequence/> tags in the module.xml files. It's not recommended to change this manually. The state of the module (enabled or disabled) is also stored in modules.

I've run some tests and for the setup:di:compile and setup:static-content:deploy it doesn't seem to matter if a module is added to the modules array. Magento will still compile and deploy the files for that module.

When running setup:upgrade Magento will regenerate the modules array and will override the previous order if necessary.

So it seems that modules is necessary for setup:di:compile and setup:static-content:deploy but the actual content of the modules array doesn't really matter.

When working with feature branches and release branches in your GIT repository config.php is a file that becomes prone to merge conflicts. And because it's not recommended to manually change this file, you need to let Magento regenerate it which is kind of a hassle when merging pull requests.

How do you manage config.php? Does anyone know a good reason why is modules necessary before running setup:upgrade?

1 Answer 1

3

It is necessary because it ensures all developers run the app with same disabled/enabled modules and config.

I run into conflicts with config.php a lot due to changed module array. I haven't put this into practice but I'm thinking of removing all unused modules from codebase with composer map directive and always have magento auto generate the module array from all modules installed, instead of committing config.php.

Of course if you use pipeline deployment and dump config then it does not work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.