Shuvankar Paul Software Engineer, Strativ AB Magento eCommerce Website Development, Website Development Using Php and HTML and Cross-Platform application development using Appcelerator.

Magento 2 Module etc/module.xml What,Why & How. Declaration Format & Explanation

1 min read

This is the First Step of Creating new Magento 2 Module.
This is called Module Declaration

module.xml Location

In your Module, for example VendorName_ComponentName Module
Create a folder called etc and there the module.xml file is called component declares file
So it will be VendorName/ComponentName/etc/module.xml

Purpose of module.xml File

  • module name declaration (moduleName)
  • module’s version (setupVersion)
  • modules’s dependency declaration with another module (moduleSequence)

Format of Declaration

For the first tag of xml will be config tag, this is generic declaration of all xml file in Magento

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
 </config>

Visit For this tag details & more about Magento 2 XML

Now Format of the module XSD (XML Schema Definition) will be found in this location
vendor/magento/framework/Module/etc/module.xsd

You will found there are only three configuration allow

  • moduleName (required)
  • setupVersion (required)
  • moduleSequence (Optional)

Module Name & Setup Version

On module under root element config, a child element called <module> on there you have to xml attribute name & setup_version, here name tag is responsible for module name & version

Module Name Format

  • Module name attribute can contain only [A-Za-z0-9_].
  • Must have at least two text with _ (underscore) at middle.
  • Regular Expression must be match with [A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}

Example : Equaltrue_Hello or Equaltrue_HelloWorld123

Avoid using “Ui” for your custom module name, because the %Vendor%_Ui notation, required when specifying paths, might cause issues.

Module version

the attribute is setup_version which is module version, this both identify the module version and schema version.
Format should be :

  • Schema version attribute can contain only [0-9.].
  • Regular Expression Must Match with [0-9.]+

schema_version is no longer needed from Magento 2.3.3

You will found all your module name & version on setup_module table
There are three column module, schema_version & data_version.
and all your install module will be app/etc/config.php

moduleSequence (Module Dependency)

Some Important Topic Related to module.xml

Maybe a question arrive what is schema_version & data_version, on that table all those column value are same then when will be it different.
A nice answer will be found this link.

Shuvankar Paul Software Engineer, Strativ AB Magento eCommerce Website Development, Website Development Using Php and HTML and Cross-Platform application development using Appcelerator.

A Full Guide to Make Mac Environment for any…

Mac is Shipped with some predefined tools for US PHP – will Depreciated in next MacOS release Apache You can check with Install Http...
Shuvankar Paul
6 min read

Disable Magento 2 Two Factor Authentication

In new Magento Version by Default Magento 2 Enable Two Factor Authentication, but if you work on localhost, then it is not useful for...
Shuvankar Paul
12 sec read

Magento 2 Common Manual MySQL Query

Getting Number of Active Product in a Category
Shuvankar Paul
54 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *