Insights
/
Magento 2 Developers
Magento 2 Developers

Snowdog Academy - Creating a New Magento Module

Learn how to create a new module in Magento with this step-by-step guide. Set up the module folder, add module.xml and registration.php files, execute t...

Dawid Czaja
Dawid Czaja
August 7, 2023
Updated
Blog Image
Key takeaways
On this page

As we’ve mentioned in the previous chapter, you should begin creating a new module by setting up three items:

1. A folder containing the module name and the name of the vendor or developer. For the purpose of the Academy, you’ll place the new module in the same directory where Magento is installed, in the app/code folder. You can do it by executing the following command. Make sure you are authorized to create files and folders in the following location: $ mkdir -p app/code/Snowdog/Academy

2. Adding the etc directory containing a module.xml file $ mkdir -p app/code/Snowdog/Academy/etc $ touch app/code/Snowdog/Academy/etc/module.xml

<?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="Snowdog_Academy" setup_version="1.0.0"/>
</config>

3. Creating a registration.php file

$ touch app/code/Snowdog/Academy/registration.php

<?php
declare(strict_types=1);

use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Snowdog_Academy',
__DIR__
);

The next step is executing the following command:

$ php bin/magento setup:upgrade

It activates the module and informs Magento mechanisms about that. After that, the information as to which modules the setup:upgrade worked on will be displayed on the screen. One of those should be the Snowdog_Academy module (it can also be a different name, depending on how you’ve named the module).

Next, by opening the app/etc/config.php file, you should be able to see an entry related to our module, along with information that it’s active.

‘Snowdog_Academy’ => 1

More information on creating new modules can be found in Magento documentation: https://devdocs.magento.com/videos/fundamentals/create-a-new-module/

Check our previous blog post from the series to learn about the module's structure.

‍

Where Snowdog comes in
See the service →
Dawid Czaja

Questions this post answers

Related reading

No items found.
On this page
Related service
See the service
Where this leads

From store to scalable.
We make Magento perform.

The eCommerce agency behind 100+ high-stakes projects, ready to build yours.

More from Insights

Shopware
The Evolution of E-Commerce (Part 2)
the-evolution-of-e-commerce-part-2
Open Source
The Evolution of E-Commerce (Part 1)
the-evolution-of-e-commerce-part-1
UX
Designing a Smooth eCommerce Experience
designing-a-smooth-e-commerce-experience
Payment Solutions
Local Feel, Global Scale
local-feel-global-scale