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 the functionality of other modules.
Each module is designed to function independently, so the inclusion or exclusion of a particular module does not typically affect the functionality of other modules.
Two possible locations:
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 an 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.
1 2 3 4 5 6 7 8 9 |
<?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.
1 2 3 4 5 6 |
<?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.
1 2 |
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.