Menu
MageQuest Logo
MageQuest
Search
MageQuest Logo

Components

Apprentice
April 19, 2020
2.3.x

What are components?

Components are the main building blocks of Magento 2. Whether the core codebase, third party extensions or your own custom development, components provide almost all the code you'll interact with when working with Magento 2.

Component Types

  • Module
  • Theme
  • Language Pack
  • Library
  • Setup

Module

Modules are the predominant component type in Magento 2 and where most developers, especially those focused on backend development, will write the majority of their code. Their purpose is to provide functionality, whether by adding new features or modifying existing ones. All the key features you associate with an eCommerce platform are provided by a module in Magento, e.g. products, categories, the cart and checkout.

As well as implementing the business logic of the features they provide, modules can also include the view (presentation) layer, such as base layout, markup, scripts and styles.

Theme

Themes, as their name suggests, are concerned with the appearance of output on the storefront (and the admin panel). While modules provide their base output for the frontend, themes are there to ensure a consistent look and feel across all modules (i.e. the site as a whole). Themes can override the layout, markup and static assets (CSS, JavaScript and images) of modules, as well as introduce new static assets of their own. If you mostly focus on frontend development, then you'll likely spend a significant amount of time working within themes.

Language Pack

Language packs facilitate one of the key selling points of Magento 2: internationalisation. They can override all the phrases (text) output across storefronts and the admin panel (via modules and themes), making translation and localisation simple to achieve, while not impacting the existing functionality.

Library

Libraries provide abstract and re-usable code that other components (in most cases modules) can implement and extend. The main library component that ships with Magento 2 is known as 'Magento Framework'. Magento Framework contains all the low-level classes and interfaces that all modules utilise and build on top of, including managing HTTP requests, interacting with the database and filesystem, the caching mechanism and the layout and templating system that renders output on the frontend.

While you can also create your own custom library components, there is little difference from creating a standalone PHP library, other than it being Magento 2 specific.

Setup

The setup component type is relatively new, only being introduced formally in Magento 2.3.0. Setup components are concerned with the preparation of the Magento application itself, both from an install and upgrade perspective. It isn't something you'll often encounter, nor will need to create, and there is only one component of this type in the core codebase.

That's the end of this tale! Now prepare to be tested in the Trial