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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay