Magento 2.x module.xml

module.xml file is a module’s naming configuration file, that is used to define module name, It is required to place this file into the below file path of module or custom module directory

magento/app/code/namespace/modulename/etc/module.xml

  • Declaration of module.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Namespace_Modulename" setup_version="3.0.1"/> 
</config>

The schema_version is no longer required since releasing Magento 2.3.3

There are following steps defined as follows:

  • module name declaration (moduleName) format : name=”Namespace_Modulename”
  • module’s version (setupVersion) format:

setup_version=”3.4.1″

There are three things in setup_module database table having three column

module : store module name as Namespace_Modulename

schema_version & data_version : The setup_version which is module version, this identify both things schema version data version as schema_version=3.4.1 & data_version=3.4.1

Module Naming convention format as follows:

  • Module Name: attribute can contain only [A-Za-z0-9_]
  • Setup Version: attribute can contain only [0-9.]

The xmlns attribute provides a location to the XMLSchema instance and the xsi:noNamespaceSchemaLocation attribute provides a path to an XSD (XML Schema Definition) file of a Magento 2 framework.

Leave a Reply

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