Magento Blog - Tutorials, Tips, News & Insights | Meetanshi
Magento Blog - Tutorials, Tips, News & Insights | Meetanshi
  • Magento Extensions
    • Magento 1 Extensions
    • Magento 2 Extensions
  • Magento Development Services
  • Blog
  • Magento 2

How to Create Module in Magento 2

How to Create Module in Magento 2

Featured In - Magento 2,

How to Create Module in Magento 2 Jignesh Parmar
Meetanshi Power Magento Store

Power-up your Magento 2 Store

Improve user experience, performance and conversion with 200+ feature rich Magento 2 Extensions!

EXPLORE NOW

The Magento 2 CMS is an excellent option to develop an online store. However, it may not be enough for modern business requirements.

To overcome the default limitations, there are Magento 2 extensions available in the market that extend the functionality of Magento 2.

You can also opt to create module in Magento 2 rather than approaching any third party extension providers.

However, you may have tons of questions regarding Magento 2 module development such as how one can develop Magento 2 module that helps the Magento 2 store to increase store facility, what are the most important things for the development of a module and so on.

Well, don’t worry.

Here we have prepared a comprehensive guide on creating your first Magento 2 module.

To create a module or extension in Magento 2, you need to create these important files.

  1. module.xml
  2. registration.php

But, before getting started, let’s discuss some of the basic things that you need to know.

The extension is built under app/code. When you go through this path, the first folder name demonstrates the name of the extension provider company. The second folder shows the name of the extension.

For easy explanation, we are here giving the name of extension “Extension” and the name of a company “Meetanshi”.

Alright. So coming back to the important files.

What you need to do is create a file having a specific path.

Steps to create a module in Magento 2:

1. Create module.xml at app/code/Meetanshi/Extension/etc 

In module.xml file, copy and paste this code.

1
2
3
4
5
6
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Meetanshi_Extension" setup_version="1.0.0">
    </module>
</config>

Now, you also need to create a file that is registration.php.

2. Create registration.php at app/code/Meetanshi/Extension

1
2
3
4
5
6
7
<?php
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
    ComponentRegistrar::MODULE,
    'Meetanshi_Extension',
    __DIR__
);

These two files are mandatory to create and get started with extension development.

How to create module in Magento 2

After creating module.xml and registration.php files, the next step is to execute commands in the command line.

1
2
3
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Run these three commands and your extension will appear in app/etc/config.php.

If the command gives output ‘0’, that indicates the extension is disabled. On the other hand, if the command shows output ‘1″, it explains that the extension is enabled and all the functionalities of the extension are working smoothly.

Magento 2 Extension Development Guide

The image explains that the name of the extension “Meetanshi_Extension” is enabled.

That’s it.

In the next tutorial, you will learn how to display a message on the frontend.

However, if you do not want the hassle of creating an extension on your own, you can visit Meetanshi for top-notch extensions developed by certified Magento developers!

Do not forget to share the series of Magento 2 module development tutorials with the beginners via social media.

Thank you.


Next
How to Create Route and Controller in Magento 2



5
(based on 10 Reviews)
How to Create Module in Magento 2Author Magento Badge

Jignesh Parmar

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.

Our Popular Magento 2 Extensions & Services









Leave a Reply Cancel reply

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

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

GooglePartner Image

Customer Service

  • About Us
  • Contact
  • Help Desk
  • Partner Program
  • Download App

Quick Links

  • Career
  • Free Magento Extensions
  • Magento Upgrade Service
  • Magento 2 Migration Service
  • Magento Hosting Providers
  • Learn Magento 2
  • Sitemap

Address

Bhavnagar HQ 303, Shiv Elite, Madhav Baug - 1, Waghawadi Road, Bhavnagar, Gujarat, India

Ahmedabad Branch 411, Arista Business Space, Sindhu Bhavan Marg, Bodakdev, Ahmedabad, Gujarat, India

+91 7202 997997

Client's Love

fbreviewfbreviewfbreviewfbreview
Facebook Shop Integration / Partial Payment / SMS Notification / PayPal Multi Currency / Image Clean / Out of Stock Notification / WhatsApp Contact / Order Tracking / Shipping Table Rates / Barclaycard Payments / Shipping Rules / Custom Order Number / Payment Restrictions / Hire Magento Developer / magento 2 Extensions
  • Refund Policy
  • EULA
  • Terms & Conditions
  • Privacy Policy

Copyright © 2017-2022 by Meetanshi. All Rights Reserved.

Share

Blogger
Delicious
Digg
Email
Facebook
Facebook messenger
Google
Hacker News
Line
LinkedIn
Mix
Odnoklassniki
PDF
Pinterest
Pocket
Print
Reddit
Renren
Short link
SMS
Skype
Telegram
Tumblr
Twitter
VKontakte
wechat
Weibo
WhatsApp
Xing
Yahoo! Mail
Powered by WP Socializer

Copy short link

Copy link
Powered by WP Socializer
We use cookies for various purposes including analytics and personalized marketing. By continuing to use the service, you agree to our use of cookies.