Hey, Amasty blog readers!

How is your preparation for the Magento 2 certification exam?

We are sticking at our answer-posts and this time we’ve asked Alexey Motorny, who passed Magento Certification in 2014 and who has been developing modules for 6+ years already, to describe (1) Magento 2 directory structure and (2) how to find the files responsible for certain functionality.


Magento 2 Directory Structure [Brief Overview]

The best way to look into the platform’s directory structure is to use a practical example. In this post, we’ll consider the locations of PHP files using one of the most extensive Magento modules — the module-catalog.

The following are the module’s components:


Let’s now examine each of them separately.


The directory contains the module’s interfaces for models and classes. For instance, the Magento\Catalog\Api\TierPriceStorageInterface interface allows us to see the structure, parameters, methods, and types of values passed for the module’s work with tier prices: Magento\Catalog\Model\Product\Price\TierPriceStorage.


This directory contains PHP files utilized for information processing. The processed data is later displayed to users with the help of the template files. Almost any content we see on Magento pages is displayed using blocks.

Most importantly, the directory contains the Adminhtml folder, which stores files used for Magento backend.


The directory is used for storing the PHP files that are responsible for console programs execution. In our case, Console/Command/ImagesResizeCommand.php processes commands for product images resizing.


The directory contains controller files that process requests sent to the server. The controllers process the input parameters and decide what information should be returned upon the request. For example, the vendor/magento/module-catalog/Controller/Product/View.php file is responsible for content displaying on a product page.


We use the directory to store the files, which are later executed on the Cron launching.


The directory contains PHP files responsible for processing information for sections. Magento 2 has a special functionality, which allows for processing, updating and transferring the information asynchronously.

For example, you can update the information on purchases and the Top Cart on request.


This is, probably, one of the most important directories. It contains the main configuration files of the module. You can find the module description, resources settings, fields description for Store Configuration, API description, plugins, observers and others in it. The configuration files let us know what the module makes and what settings are utilized for the operations.

To find more information on the configuration files, follow the link.


The directory contains PHP helper files that include some aggregated functionality, which can be utilized in different module’s parts.


This directory stores CSV files, which allow you to transfer the module to different locales.


The directory contains all the files that work with the database tables. They allow for receiving and processing information from the tables, adding and deleting it. The simplest example is getting product information.


This directory includes the PHP files responsible for executing commands from the listener. Magento code includes events, which we can apply to add listeners with the use of vendor/magento/module-catalog/etc/events.xml. We can also use the events to change or read the needed information.


The directory comprises plugin files. The plugins allow us to modify certain module’s functions if necessary. They are described in the configuration file: vendor/magento/module-catalog/etc/di.xml.

Learn more about the directory from here.


This directory contains scripts interacting with the database. For example, we will use the setup directory if we need to create a table when installing a module.


The directory is used to keep integration tests. All the required test files are located here.


Many functional elements of Magento 2 Admin Panel are developed using the technology of UI components. This UI directory contains files for data generation, which later receive, process and show the components on a display.


In this directory you can find all the visual files: .js, .css, .html, .phtml, .xml, or, simply, all the files we see on the frontend. The files are divided into three categories relying on the area of the operation:


Frontend Files

The following files can be found in each directory we have considered above.

Layout (the .xml files)

The files define what blocks and in what order will be shown on the display.

Templates (the .phtml files)

The files contain HTML structure a user will see on the display.

UI_component (the .xml files)

The files keep the configuration of the UI components. They determine where to display the components and with what templates.


We use the directory to locate .js and .css files, as well as images required for markup.

Besides, we also need to mention the view/frontend/web/template directory. It’s used to locate .html files applied for the UI components.


The file defines the directory in which the component is installed by vendors (in the production environment). By default, components are automatically installed by the composer in the <Magento root dir>/vendor directory.

See the component registration guide for more information.


The file defines component dependencies, as well as other metadata.

To learn more about it, follow the link.

In summary, we have described where to locate and find the PHP files depending on their functionality. We also mentioned where to place the style, .html files and hope it was helpful!

Drop us a line if you still have questions on the topic.

P.S. Stay tuned and check our next posts in preparation for the Magento 2 certification exam!