How to navigate magento stack


At Ampersand, our chosen ecommerce platform is Magento 2. One of our Backend Developers, Omotola shares an introduction and how-to guide for developers interested in learning more about the Magento stack  

You’re probably familiar with platforms like Shopify, well Magento is similar, with the key difference being that the platform is provided as an open-source application which allow developers and businesses to customise it for different market needs.

The Magento 2 platform is a flexible, open-source commerce platform and content management system. Written in PHP, it’s extremely configurable and leverages elements of Zend Framework, now known as Laminas and MVC architecture. You are able to extend or customise any existing component in the Magento application providing you have a good understanding of PHP and knowledge of how Magento works. You can also create components that introduce new functionality and distribute them to merchants building stores with Magento 2. 

Tools and Setup

Some of the tools we use for our setup internally include: 

  • Database − MySQL 5.7 – 8
  • Web Server − 
    • Apache 2.x
  • Operating System − Mac OS
  • Composer – Package manager
  • Browser Support − Google chrome
  • SSL (Secure Socket Layer) − A valid security certificate is required for HTTPS
  • PHP Compatibility − PHP 7+ (Depending on project requirements we are able to swap versions)
  • Varnish – For web caching 
  • Strap – A script that configures the development system i.e (Mac OS)
  • Makefile & Brewfile – For project setup
  • Docker – For setting up Testing & Development environments, also responsible for setting up other services like MySQL, Redis & Varnish.
  • IDE –
    • Vscode
    • PHPStorm
Learning curve

To start navigating the Magento stack, you have to be aware of what makes up the Magento application – modules, themes and language packages. 

Modules are the building blocks, they’re an independent component which provides business/functional logic bringing additional features to an ecommerce website. If we take a catalogue module for example, it gives us the ability to manage products, categories, product types and catalogue browsing. The module also allows for extensibility to its current functionality.

Themes are used to customise the look and feel of the Magento storefront and admin panel. Language packages are used for providing translation displays for strings in a customer-facing interface. 

To create modules we have to register the module and create a configuration file for modules settings. Configuration files are a big part of the Magento ecosystem and they’re written in xml.  The purpose of these kinds of files are for various configuration activities involving theming, languages, routes, module setup and referencing site areas. 

There are two places you can find Magento modules, for custom modules they are found in the app/code directory, while all third party modules are installed into the vendor directory. Most modules in the vendor directory are downloaded and managed using the composer package manager.

Magento modules are distributed as vendor packages, so when creating one in the app/code directory, the name of the folder is normally the /. 

For example, if I wanted to create a module for Ampersand I would create two folders like so: AmpersandHQ/StoreModule. 

Each area that makes up the Magento application follows this file structure convention.

To notify the Magento application that a new module is being registered it would need two more files – registration.php file and an etc/module.xml file. 

Common module directories include:

  • Block: This includes files that are used to render view components. It extends the Magento core View Class which follows principles from the MVC pattern.
  • Controller: This folder holds controller classes that handle actions for a Magento routed page. All classes extend the Action Controller and represent C in the MVC pattern. 
  • Model: This folder holds all the data representations for Magento attributes. It represents the M in MVC.
  • Etc: This includes all configuration files.
  • Setup: Includes classes for module database structure and data setup. It is invoked when a module is installed for the first time or upgraded.

Other folders you might come across include:

ViewModel, Api, Observer (Event Driven Actions), Plugin (Extensibility), View, UI, Vendor, Plugins and Observers. 

In conclusion, Magento 2 is a highly flexible and scalable platform that allows developers to customise it for various business needs. If you would like to go over the documentation for some more insights about the platform, you can read about this here.

The Magento 2 platform also has a great community surrounding Magento news, best practices and some step-by-step guides on how to implement certain features. 

If you’re interested in developing your career and learning more about Magento 2,  head to our careers page to view all of our current engineering opportunities.