0

I know now that xml files in M2 are being red/parsed by

\Magento\Framework\Config\Reader\Filesystem.php 

PART 1 : Can someone explain briefly the different existing .xml types (by types i mean config.xml is one type, system.xml is another type) in M2 modules and what purpose do they server. Like :

1) module.xml - used for declaring the module and the module dependencies on other modules...
2) config.xml - used for....
3) system.xml - used for....
4) layout.xml - used for....
5) ....xml - used for .....

PART 2 : Are all .xml file types that we see in the core modules sort of "predifined" by the System, to make it more clear - the system receives files like I mentioned in PART 1 and knows that it has to read them, but if it receives a file that I talk of in PART 3 or like it was given in the example that I pointed out (table.xml) you have to extend and change the child class of \Magento\Framework\Config\Reader\Filesystem.php class.

PART 3 : Also, if I need a file that is not predefined to get parsed by the system how should one proceed with parsing and including this file.

I know this is an extensive question, but I think it will help a lot of developers who are having first time experience in Magento2 as the system looks very complex. Thank you.

EDIT:

I think this explains the custom PART 3 if no one can suggest another option. How can I have a custom XML file in modules merged as one in Magento 2? (MageStackDay mystery question 2)

2

Some configuration files:

  • config.xml: default configuration settings for your module.
  • module.xml: declare module & dependencies
  • acl.xml: access restrictions for adminhtml
  • system.xml: can be used e.g. to declare configuration module, next to other settings
  • layout.xml: define layout instructions (e.g. extra blocks, to remove blocks, etc.)
  • routes.xml: define routes to your controllers
  • And some more files :)

Some background: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/required-configuration-files.html & http://devdocs.magento.com/guides/v2.0/config-guide/config/config-files.html.

I would advise you to take a look at some Magento 2 sample modules. Look in their /etc folders and see what the XML files are used for, e.g. here: https://github.com/magento/magento2-samples/tree/master/sample-module-shipping-provider/etc.

Some files need a certain file name, some don't. It depends a bit on the situation. Besides that the XML files can have an XSD declaration to check the validity of them, besides that it can help you in your IDE to get clear how to use them: http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-urn.html.

Regarding part 3, I think the suggest link does the job indeed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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