MageQuest Logo
MageQuest Logo

Module Basics

December 17, 2019

What are modules?

Modules provide all the core functionality Magento offers that build on top of the framework code and also the way for developers to add their extended functionality to the platform.

As their name suggests, they are modular collections of code designed to work independently from one another, or in many cases, depend on other modules and extend their functionality.

A module can contain many different types of code for a wide variety of purposes, which we'll cover below.

Generally speaking, small, concise modules with minimal dependencies make for better code maintainability and interpolation, but in the Magento core modules can range from micro to monolithic.

Core Magento 2 module examples

  • Magento_Catalog - contains all key functionality concerning products and categories (and more!)
  • Magento_Checkout - contains all key functionality concerning the cart and checkout process
  • Magento_Cms - contains all key functionality concerning CMS pages and blocks

Module naming

Note all the Magento modules above contained 'Magento', followed by an underscore then a descriptive word relating to the module (e.g. 'Checkout'). These form a modules name, broken down as follows:


Where <Vendor> is the name of the module provider/creator and <ModuleName> is the name of the module.

So, for example, a module that adds image banners to CMS pages by a company called 'My Awesome Company' might be named MyAwesomeCompany_CmsBanners

Some informational tip

Note the CamelCasing used in the modules vendor and name. Camel casing is not required, but follows how Magento name their core modules. However both the vendor and module name should begin with a capital letter at a minimum.

Module location

By default, modules can be included in 2 places within a Magento 2 project:

  1. Within the app/code directory
  2. Within the vendor directory (this is where all modules installed via composer reside)
That's the end of this tale! Follow the Walkthru to put what you've learnt into practice