DEV Community

Lê Vĩnh Kỳ
Lê Vĩnh Kỳ

Posted on

How to Create Module in Magento 2

We will discuss the topic of how to create simple module called **Kyle Wiley **in Magento 2

There are 2 things must have when create Magento module: module.xml, registration.php

Step 1: Create the folder of Kyle Wiley module

 app/code/Kyle/Wiley
Enter fullscreen mode Exit fullscreen mode

So it's gonna be like Kyle_Wiley, Kyle_Wiley it's module name

Step 2: Create etc/module.xml file.

app/code/Kyle/Wiley/etc/module.xml
Enter fullscreen mode Exit fullscreen mode

Content would be:

<?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="Kyle_Wiley">
    </module>
</config>
Enter fullscreen mode Exit fullscreen mode

Step 3: Create registration.php file

app/code/Kyle/Wiley/registration.xml

Content would be:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Kyle_Wiley',
    __DIR__
);
Enter fullscreen mode Exit fullscreen mode

Step 4: Enable our new module

Finish the step 3, we have already created the Kyle_Wiley module. And we will enable this module in this step

After create the module if you run the command as:

bin/magento module:enable Kyle_Wiley
Enter fullscreen mode Exit fullscreen mode

And for sure you should run

bin/magento setup:upgrade
Enter fullscreen mode Exit fullscreen mode

Top comments (0)