As we know, we need to create a custom module in magento2 to override or impliment new feature in magento.

So in this tutorial we will create a custom module. We need to follow simple step to create module.

Follow below 4 step for create module.
1. Create the module folder at project path app/code/<vendor>/<module_name>
2. Create the etc/module.xml file in module
at app/code/<vendor>/<module_name>/etc/module.xml

PHP
<?php

declare(strict_types=1);

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'MageDad_Module',
    __DIR__
);

Above code in MageDad is <vendor> and Module is<module_name>

3. Create the registration.php file in module
at app/code/<vendor>/<module_name>/registration.php

PHP
<?php

declare(strict_types=1);

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'MageDad_Module',
    __DIR__
);


4. Run command php bin/magento setup:upgrade at root path in terminal to register module.

5. Verify app/etc/config.php file. There is module register like below screenshot.

How to Create a Custom Module in Magento 2?

You can see this commit of create simple module
You can follow official adobe document for create a module.

I hope this blog is useful to Create a Custom Module in Magento2. In case, I missed anything or need to add some more information, Don’t heisted to leave a comment in this blog, I’ll get back with some positive approach.

Keep loving ❤️ Keep inspiring 🤩 Keep liking 👍 No sharing 😂

3 Comments

  1. I would like to thank you for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming also. Actually your creative writing skills has encouraged me to get my own website now. Really the blogging is spreading its wings rapidly. Your write up is a good example of it.

Write A Comment