To create basic Magento 2 module you need only 2 files: module.xml and registration.php.

1. Firstly, create the module's folder:


and the folder that will contain the module configuration files:


If the app/code folder is missing from your Magento 2 installation, please create one.

2. Place the module.xml file with the following contents in the app/code/<VendorName>/<ModuleName>/etc/ folder

<?xml version="1.0"?>

<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="VendorName_ModuleName" setup_version="2.0.0">
            <module name="Magento_Cms"/>
            <module name="Magento_Catalog"/>

sequence is not a required element and is intended to define the modules which your module depends on. If the dependencies are unknown, they can be specified later.
setup_version — defines the current version of the module.

3. Create a registration.php file and place it in the app/code/<VendorName>/<ModuleName>/ folder.



In the examples, we will create a module Magefan_Faq for Frequently Asked Question (FAQ).

The resulting structure of the module will look like this:

├── app
│   └── code 
│        └── Magefan // назва розробника - VendorName
│            └── Faq
// назва модуля - ModuleName
│                ├──
│                │   └──
│                │
│                └──

On GitHub you can view the files of the Magefan_Faq module.

After creating these 2 files, register the module in the system. Open CLI (terminal, command line), then go to the Magento 2 root folder and run the following command:

php bin/magento setup:upgrade

It checks for new and updated system components (modules, themes, language packs), installs and updates them.

You can check if the module is installed and enabled in this file


there must be the following string in it

'VendorName_ModuleName' => 1

We have created the simplest module for Magento 2. It is a separate unit, though it does not have any functionality yet.

Read more on how to create your own controller and display "Hello World".