How Magento 2 identify module

Written by Payal Patel

Oct 10, 2020

How Magento 2 identify module

A module is a logical group – that is, a directory containing blocks, controllers, helpers, models – that are related to a specific business feature.

The purpose of a module is to provide specific product features by implementing new functionality or extending other modules’ functionality.

Each module is designed to function independently, so the inclusion or exclusion of a particular module does not typically affect other modules’ functionality.

Two possible locations to magento 2 identify module

app/code: If you build a module for a specific project, it is best to

choose the app/code folder and commit to the project’s repository.

vendor/<your_vendor>/module-somethingname: If you build a Magento 2 extension to be reused, it is better to use composer to create it, and put your module in the vendor/<your_vendor>/module-something folder.

There are two required files:

  • registration.php
  • module.xml

Step 1: The registration.php file inside the app/code/Dolphin with the following code.

<?php

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Dolphin_MyModule',
__DIR__
);

Step 2: The module.xml file inside the app/code/Dolphin/etc with the following code.

<?xml version="1.0"?>

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

Step 3: Run Magento Upgrade and Cache Clean command.

php bin/magento setup:upgrade
php bin/magento cache:clean

Now, go to app/etc folder open config.php file, and you can see your Dolphin_MyModule.

We hope our technical blog which looking is very effective for you. If any questions, please feel free to leave a comment below.

In the next tutorial, you will help How to create a basic module in Magento 2.

Payal Patel

Author

We can help you with

  • Dedicated Team
  • Setup Extended Team
  • Product Development
  • Custom App Development

Schedule a Developer Interview And Get 7 Days Risk-Free Trial

Fill out This Form and one of Our Technical Experts will Contact you Within 12 Hours.

    Google
    |

    4.8

    Google
    |

    4.8

    Google
    |

    4.9

    Google
    |

    4.8

    Google
    |

    4.9

    Copyright © 2024 DOLPHIN WEB SOLUTION. All rights reserved.

    TO TOP