6

Is there a way to merge multiple di.xml files into one main di.xml configuration file?

I would like to split a big di.xml file into five different files. I have seen the include command in the system.xml file into the PayPal module and I am curious to know if I can split the di.xml file too.

Look at:

https://github.com/magento/magento2/blob/develop/app/code/Magento/Paypal/etc/adminhtml/system.xml#L40-L43

1 Answer 1

5

You cannot split the di.xml file inside a module into multiple parts other than the ones supported by Magento.
All you have to work with is:

  • etc/di.xml - the main di file. Loaded everytime.
  • etc/frontend/di.xml - loaded only on frontend
  • etc/adminhtml/di.xml - loaded only on backend.

The include tag in the system.xml files works because it is interpreted when the system.xml files are interpreted. So it is system.xml specific.
There is nothing similar for di.xml files.

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.