Beginner’s Guide Magento #01: Structure and Core Principles

Let’s be honest: the first time you open a Magento project, you only want one thing… run as far away from the computer as possible. XML everywhere, folders in every direction, the whole thing looking like something straight out of a James Wan movie. But don’t worry. In this series, I’ll guide you step by step, as if I were sitting right next to you, calmly explaining everything you’re looking at.

The goal of this first article is simple. To give you a clear overview of Magento 2’s structure, its core principles and the files you’ll encounter within your very first minutes on a project.


Understanding Magento’s modular architecture

Magento is a fully modular e-commerce framework. Every feature, even the simplest one, exists in its own module. This fine-grained structure can look intimidating at first, but it is also what makes Magento extremely flexible and extensible.

What a module does

A Magento module is an organized set of files that together provide one specific feature. Magento runs by aggregating dozens of core modules, plus vendor modules and your custom ones.

A typical module contains:

  • an etc/module.xml file declaring the module
  • a registration.php file registering it to the framework
  • optionally, folders like etc, Model, View, Block, Controller, Plugin, Observer, etc.

Listing installed modules

bin/magento module:status

A very useful command to instantly visualize the active and disabled modules on the project.

How modules are loaded

Magento scans all module.xml files, resolves dependencies, builds a loading order and activates file scopes accordingly.
This order impacts layout overrides, preferences, plugins and every type of extension mechanism.


Exploring the folder structure

Let’s walk through the root directories so you know exactly what lives where.

app

This is where most of your application’s custom logic resides.

  • app/code stores custom modules.
  • app/design stores themes and view overrides.
  • app/etc contains global configuration (env.php, config.php).

vendor

This directory is fully managed by Composer. It contains Magento itself plus all third-party dependencies.
You never modify anything here manually.

composer update
composer require <package>

pub

This is the public-facing area of your project. Compiled assets, images and generated files are exposed here in production.

generated

Magento generates classes like factories, proxies and interceptors here.
If something goes wrong in development, clearing this directory is common practice:

rm -rf generated/*

var

Logs, cache, reports and sessions live here.
To clear the cache:

bin/magento cache:flush

Understanding Composer and dependency management

Composer is the backbone of modern Magento development. Without Composer, no professional Magento setup is possible.

Why Composer matters

Composer handles three critical tasks:

  • installing Magento and all its dependencies
  • locking versions in composer.lock to ensure consistency across environments
  • generating PSR-4 autoloading

composer.json

This is the heart of your project dependencies:

{
    "require": {
        "magento/product-community-edition": "2.4.6",
        "php": "^8.1"
    }
}

Installing Magento via Composer

Before you install Magento with Composer, you must generate your Adobe Commerce authentication keys. These keys allow you to access repo.magento.com, which is required to download Magento’s core packages.

Get your keys here:
https://experienceleague.adobe.com/fr/docs/commerce-operations/installation-guide/prerequisites/authentication-keys

Once your keys are configured, you can create a fresh Magento project:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .

Conclusion

Magento’s architecture may look intimidating, but once you understand its structure and modular logic, everything starts to fall into place. You now know where to look, what the main directories do and how Composer ties everything together.

In the next episode, we will dive into XML configuration, dependency injection and the internal mechanisms that power Magento’s flexibility.

And if you want to run quickly and efficiently your first magento 2’s local website, you can think about use warden !

meme beginner's guide magento 1