The module presents the behavior of the Magento framework. Magento provides multiple default modules for eCommerce functionality. But if you want to add some different functionality then you need to create a custom module in Magento. In this blog, I am going to show you how to create a custom module in Magento 2.

Below way, you can create a custom module in Magento 2.

First, you need to create a module directory under the vendor directory. For example : [Magespark\HelloWorld].

Magespark is vendor and HelloWorld is Module which is contained on [app\code] directory.

you need to register the module in Magento using the \Magento\Framework\Component\ComponentRegistrar class.

registration.php

[Magespark\HelloWorld\registration.php]

module.xml

[Magespark\HelloWorld\etc\module.xml]


Run the “setup:upgrade” command ::

Running this command makes your new module active, notifying Magento of its presence.

php bin/magento setup:upgrade