vitales coupons hudsonville superdrug simple gift sets 2tails coupon code biscoff coupon hollister gift card balance phone number can i use banana republic gift card at old navy

Create module in magento 2

There are small changes in the process of creating a module in Magento 2 as compared to Magento 1.Before knowing the steps,one should know required files and folder structure for modules in Magento 2.

Folder Structure of modules

First change in Magento 2 folder structure is,Code pool (local/community) is removed. You can place your module folder in app/code/<vendor_name>.create module in magento 2

Inside module folder,there is no much change in folders,some folders and files are added.create module in magento 2 - folder structure magento 2

Required Files for modules

  • registration.php : Registers the module in Magento system.
  • composer.json: Specifies component dependencies and includes basic information about module like name,version,type etc.

These files are required to register your module in Magento. For content in these files find link below to download the basic module.

Steps to create module in Magento 2

  1. Create folders as per above folder structure.
  2. Create new registration.php with module name.(For content check this page)
  3. Create file composer.json.(For all available options in this file check this page)
  4. Now declare the module by module.xml file in etc folder. This file is similar to app/etc/<vendor_module>.xml  file in Magento 1. We don’t need to declare modules in app/etc folder in Magento 2.It consist of Module name and version of Magento that module uses.
  5. Enable this module by running these commands:
    1. bin/magento module:enable --clear-static-content Module_Name
    2. bin/magento setup:upgrade
  6. Refresh cache if it is enabled.
  7. You can check your module in Stores->Configuration->Advanced->Advanced.
  8. In newer versions, you can check modules in System > Web setup wizard > Module Manager.

Additional Notes:

  • You might not find code folder in app folder,because all default magento folders are in root/vendor folder.
  • Same as theme layout files, config files will be in parts. For frontend config you can place .xml files in module/etc/fronend folder,same as for admin config, .xml files will be in etc/adminhtml folder.For global config place xml files in etc folder itself.

You can download sample module from here.This extension is to check content of files and to view folder structure only. Do not install it.

Now learn about Magento 2 theme development.

The following two tabs change content below.
Ankur Dholakia

Ankur Dholakia

Magento Developer | Entrepreneur at iBiz Technologies
Magento Developer, Entrepreneur, Day Dreamer!


  • hi
    I got a question the only code folder i can find is in de root/update/app/code
    and ,i think, most of the modules are in the root/vendor/magento.
    So mine question is where can i put the modules i make mineself?
    I installed magento2 using composer and the metapackage
    thanks for any help you can give me

    • Ankur Dholakia


      You can place your Vendor folder in app/code. And module folders in that Vendor folder.

      Ankur Dholakia
      • thanks you for answering,
        so do i just put the vendor map in de app/code so in mine case it looks like root/update/app/code/vendor
        or do i make a whole new app folder so it looks like root/app/code/vendor
        i got the root/app and within that app folder i got design and an etc folder.

        • hi,
          thanks for your help the problem has been solved
          again thanks

          • Ankur Dholakia

            Great! Glad this helped you.

            Ankur Dholakia

Leave a Reply

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

Start typing and press Enter to search

Shopping Cart