Magento Extension Development- Simple Method

Magento Extension Development

Magento consists of different modules for different purposes . Module is a structural element of Magento 2. A module can be created externally or from reusable modules inside the vendor/folder.The location of the new module created is in app/code/(new_module)/.The main use of the module is for customization in Magento.

Steps for creating a Module

  • Creating the module folder-inside app/Code/<vendor>/<module>/etc
  • Creating the module.xml file inside etc folder
<?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=”Learning_firstunit” setup_version=”0.0.1″> </module> </config>

Learning_firstunit is my module name.

  • Create the registration.php file

There must be a registration.php inside every module folder here it is in

app/code/Learning/firstunit/registration.php

The Code for registration.php is given below

<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, ‘Learning_firstunit’,__DIR__);
  • Now open the terminal from your root magento2 folder and Run

php bin/magento setup:upgrade

  • Check that the new module is active
grep Learning_firstunit app/etc/config.php

By this method we can create module in Magento2

Enable the module in Magento 2

php bin/magento module:enable Learning_firstunit

Employing these steps, you can successfully create a new module in Magento 2.

Leave a comment

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